JDK-7087658 : MethodHandles.Lookup.findVirtual is confused by interface methods that are multiply inherited
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs23,hs24,7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2011-09-07
  • Updated: 2013-11-12
  • Resolved: 2013-07-17
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.
7u40Fixed 8Resolved
Related Reports
Blocks :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
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.

The newer duplicate is a simpler description of the bug, and includes an apparent fix.

Can we close this bug as a duplicate of JDK-8014013?

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.

Can you see if this is still an issue for 8?

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-main/jdk/rev/556141c6326c