JDK-4990369 : SAJDI: visibleMethods() and methodsByName() return wrong visible methods
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: e6u21,hs25,5.0,8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic
  • Submitted: 2004-02-06
  • Updated: 2016-04-15
  • Resolved: 2014-01-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b02Fixed
Related Reports
Duplicate :  
Relates :  
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

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

Comments
RULE nsk/sajdi/ReferenceType/visibleMethods/vsbmethods001 ExitCode 97
17-01-2014

the test still fail with JDK8
20-08-2013

EVALUATION ###@###.### 2004-02-09 Not a tiger showstopper. This is not a regression, it has always worked this way.
09-02-2004