Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4990369

SAJDI: visibleMethods() and methodsByName() return wrong visible methods

    Details

    • Subcomponent:
      svc
    • Resolved In Build:
      b02
    • CPU:
      generic
    • OS:
      generic, linux

      Description



      Name: ipR10196 Date: 02/06/2004


      --------------------------------------
      Test : nsk/sajdi/ReferenceType/visibleMethods/vsbmethods001
                    nsk/sajdi/ReferenceType/allMethods/allmethods001
      VM : ClientVM, ServerVM
      Mode : all
      Platform : generic
      OS : SunOS 5.8
      JDK : 1.5.0 b32-b36
      ----------------------------------------

      This SA-JDI test checks if method ReferenceType.visibleMetods()
      returns only visible methods either declared in tested class or
      inherited from its superclass and implemented interfaces.

      Also for each visible method methodsByName() is expected to return methods
      list with this method included. And for each non-abstract visible method
      concreteMethodByName() is expected to return methods corresponing method.

      The test demonstrates that for either SA-JDI and legacy JDI connectors
      some hidden methods are wrongly reported as visible and vice versa.

      This test checks a lot of methods of various classes and so it is
      complicated enough. I simplified the test by removing unnecessary
      checks and methods, so this failure is clearly reproduced.

      The simplified version of the test declares following methods
      in a tested class, its superclass and implemented interfaces:

          interface SuperInterface {
              public void methodOverridenSuperInterfacePublicArgs(int i);
              public void methodOverridenSuperInterfacePublicArgs(String s);
              public String methodAmbigousSuperInterfacePublicEmpty();
          }

          interface Interface1 extends vsbmethods001aSuperInterface {
              public void methodOverridenSuperInterfacePublicArgs(int i);
              public Object methodAmbigousInterface1PublicArgs(int i, long l);
          }

          interface Interface2 extends vsbmethods001aSuperInterface {
              public void methodOverridenSuperInterfacePublicArgs(String s);
              public Object methodAmbigousInterface1PublicArgs(int i, long l);
          }

          interface Interface3 {
              public String methodAmbigousSuperInterfacePublicEmpty();
          }

          abstract class SuperClass implements Interface1, Interface2 {
              public vsbmethods001aSuperClass() { super(); }
          }

          abstract class TestedClass extends SuperClass implements Interface3 {
              public vsbmethods001aTestedClass() { super(); }
          }

      Here both overloaded methods of SuperClass:

              methodOverridenSuperInterfacePublicArgs(int)
              methodOverridenSuperInterfacePublicArgs(String)

      are overriden in Interface1 and Interface2 respectively and thus are
      NOT visible in TestedClass. The corresponding methods of Interface2
      and Interface3 should be returned by visibleMethods().

      For second of these overloaded methods correct method of Interface2
      is returned:

          method #14
            method name: methodOverridenSuperInterfacePublicArgs
            signature: (Ljava/lang/String;)V
            decl type: interface
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
                          (loaded by instance of
      sun.misc.Launcher$AppClassLoader(id=0))
            type name:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
            isConstruct: false
            isSynthetic: false
            toString:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2.
                              methodOverridenSuperInterfacePublicArgs(java.lang.String)
            ... found in expected list: #4
            check methodsByName(name,sig):
              methods count: 1
              - decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
              found index: 0
              found method:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2.
                              methodOverridenSuperInterfacePublicArgs(java.lang.String)
                 decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
                    equals: true
            check concreteMethodByName(name,sig):
              got method: null

      However, for the first of these overloaded methods hidden method
      of SuperInterface is wrongly returned by visibleMethods().
      The same hidden method is also wrongly returned by methodsByName():

          method #16
            method name: methodOverridenSuperInterfacePublicArgs
            signature: (I)V
            decl type: interface
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
                          (loaded by instance of
      sun.misc.Launcher$AppClassLoader(id=0))
            type name:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
            isConstruct: false
            isSynthetic: false
            toString:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface.
                              methodOverridenSuperInterfacePublicArgs(int)
            ... found in expected list: #7
            check methodsByName(name,sig):
              methods count: 1
              - decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
              found index: 0
              found method:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface.
                              methodOverridenSuperInterfacePublicArgs(int)
                 decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
                    equals: true
            check concreteMethodByName(name,sig):
              got method: null
          <...>
          # ERROR: ReferenceType.visibleMethods() returned no expected visible method:
          # ERROR: method name: methodOverridenSuperInterfacePublicArgs
          # ERROR: signature: (I)V
          # ERROR: declared in: Interface1
          # ERROR: found count: 0
          <...>
          # ERROR: ReferenceType.visibleMethods() returned unexpected invisible
      method:
          # ERROR: method name: methodOverridenSuperInterfacePublicArgs
          # ERROR: signature: (I)V
          # ERROR: declared in: SuperInterface
          # ERROR: found count: 1

      The following methods with the same signature are declared
      in different interfaces and so are ambigous:

              Interface1.methodAmbigousInterface1PublicArgs(int,long)
              Interface2.methodAmbigousInterface1PublicArgs(int,long)

              SuperInterface.methodAmbigousSuperInterfacePublicEmpty()
              Interface3.methodAmbigousSuperInterfacePublicEmpty()

      As these methods are never overriden, they all should be reported
      as visible. However, only one method in each pair is returned by
      visibleMethods() and methodsByName():

          method #15
            method name: methodAmbigousInterface1PublicArgs
            signature: (IJ)Ljava/lang/Object;
            decl type: interface
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
                          (loaded by instance of
      sun.misc.Launcher$AppClassLoader(id=0))
            type name:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
            isConstruct: false
            isSynthetic: false
            toString:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2.
                              methodAmbigousInterface1PublicArgs(int, long)
            ... found in expected list: #5
            check methodsByName(name,sig):
              methods count: 1
              - decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
              found index: 0
              found method:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2.
                              methodAmbigousInterface1PublicArgs(int, long)
                 decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aInterface2
                    equals: true
            check concreteMethodByName(name,sig):
              got method: null
          <...>
          # ERROR: ReferenceType.visibleMethods() returned no expected visible method:
          # ERROR: method name: methodAmbigousInterface1PublicArgs
          # ERROR: signature: (IJ)Ljava/lang/Object;
          # ERROR: declared in: Interface1
          # ERROR: found count: 0

          method #17
            method name: methodAmbigousSuperInterfacePublicEmpty
            signature: ()Ljava/lang/String;
            decl type: interface
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
                          (loaded by instance of
      sun.misc.Launcher$AppClassLoader(id=0))
            type name:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
            isConstruct: false
            isSynthetic: false
            toString:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface.
                              methodAmbigousSuperInterfacePublicEmpty()
            ... found in expected list: #1
            check methodsByName(name,sig):
              methods count: 1
              - decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
              found index: 0
              found method:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface.
                              methodAmbigousSuperInterfacePublicEmpty()
                 decl type:
      nsk.sajdi.ReferenceType.visibleMethods.vsbmethods001aSuperInterface
                    equals: true
            check concreteMethodByName(name,sig):
              got method: null
          <...>
          # ERROR: ReferenceType.visibleMethods() returned no expected visible method:
          # ERROR: method name: methodAmbigousSuperInterfacePublicEmpty
          # ERROR: signature: ()Ljava/lang/String;
          # ERROR: declared in: Interface3
          # ERROR: found count: 0

      To reproduce this failure with simplified testcase:
        cd /net/jano.sfbay/export/disk20/GammaBase/Bugs/<this bug number>
        sh build.sh $JAVA_HOME
        sh run.sh [-pid | -core | -socket] [-g] [-v] $JAVA_HOME [JAVA_OPTS]
      where:
          -pid - run test with SA-JDI pid attaching connector (default)
          -core - run test with SA-JDI core attaching connector
          -socket - run test with JDI socket attaching connector
          -g - run test with java_g binaries
          -v - run test in verbose mode

      The original testcase will be available in the next r27 testbase release.

      Running with SA-JDI connectors on Linux platform this test is crashed
      because of known bug:
      4975660 SA-JDI: SAPIDAttachingConnector.attach() causes debugger VM crash on
      Linux

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sla Staffan Larsen (Inactive)
                Reporter:
                popovsunw Popov Popov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: