United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7087658 MethodHandles.Lookup.findVirtual is confused by interface methods that are multiply inherited
JDK-7087658 : MethodHandles.Lookup.findVirtual is confused by interface methods that are multiply inherited

Details
Type:
Bug
Submit Date:
2011-09-07
Status:
Closed
Updated Date:
2013-11-12
Project Name:
JDK
Resolved Date:
2013-07-17
Component:
hotspot
OS:
linux
Sub-Component:
compiler
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
hs23,hs24,7
Fixed Versions:
8

Related Reports
Backport:
Backport:
Backport:
Blocks:
Duplicate:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
Given this test case:

interface A {
   Iterable m(List<String> ls);
}

interface B {
   Iterable<String> m(List l);
}

interface AB extends A, B { }

interface AA extends A { }


If I do:

       MethodHandle mh1 = MethodHandles.lookup().findVirtual(A.class, "m", MethodType.methodType(Iterable.class, List.class));
       MethodHandle mh2 = MethodHandles.lookup().findVirtual(B.class, "m", MethodType.methodType(Iterable.class, List.class));
       MethodHandle mh3 = MethodHandles.lookup().findVirtual(AB.class, "m", MethodType.methodType(Iterable.class, List.class));
       MethodHandle mh4 = MethodHandles.lookup().findVirtual(AA.class, "m", MethodType.methodType(Iterable.class, List.class));

I would expect all the lookups to succeed.  However, only lookups for A, B, and AA succeed; lookups for AB fail with

 java.lang.NoSuchMethodException: no such method: AB.m(List)Iterable

It fails the same way when the generics are removed.  So it appears to be a problem with an interface multiply inheriting the same method and not overriding it.

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/jdk/rev/556141c6326c
                                     
2012-08-11
Can you see if this is still an issue for 8?
                                     
2013-04-30
This bug is consistent with another, simpler problem.  Interface methods which should be inherited from super-interfaces are not visible (sometimes) to Lookup.findVirtual.  For a simple demonstration, see attached file intfbug.zip.

Bug JDK-8014013 is intended to fix such problems by unifying method handle lookup with normal byte behavior lookup.
                                     
2013-06-11
Can we close this bug as a duplicate of JDK-8014013?
                                     
2013-07-15
The newer duplicate is a simpler description of the bug, and includes an apparent fix.
                                     
2013-07-17



Hardware and Software, Engineered to Work Together