JDK-8016841 : JSR292: lookup failure of a default method inherited from a parent
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-06-18
  • Updated: 2013-10-21
  • Resolved: 2013-07-03
Related Reports
Duplicate :  
Description
Lookup of a default method inherited from a parent interface fails.

Pseudo-code:
  interface I { int m() default { return 1; } }
  interface J extends I {}
  interface K extends I {}
  class C implements J, K {}

J o = new C(); o.m();

Result:
  expected: o.m() == 1;
  actual: o.m() throws chain of (AME => IAE => ICCE) exceptions

Fails with: MH.invokeExact, MH.invoke, MH.invokeWithArguments, invokedynamic.

The test passes when invocation is done using invokeinterface on bytecode level.

Invocation (for MH.invokeExact case):
         0: ldc           #16                 // MethodHandle invokeinterface J.m:()I
         2: new           #18                 // class C
         5: dup           
         6: invokespecial #19                 // Method C."<init>":()V
         9: astore_1      
        10: aload_1       
        11: invokevirtual #25                 // Method java/lang/invoke/MethodHandle.invokeExact:(LJ;)I

Failure:
Exception in thread "main" java.lang.IncompatibleClassChangeError
	at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:383)
	at Test2_J_C_m.test(Unknown Source)
	at Test.main(Test.java:3)
Caused by: java.lang.IllegalAccessException: no such method: J.m()int/invokeInterface
	at java.lang.invoke.MemberName.makeAccessException(MemberName.java:761)
	at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:882)
	at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1037)
	at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1342)
	at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:381)
	... 2 more
Caused by: java.lang.AbstractMethodError: J.m()I
	at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
	at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:854)
	at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:879)
	... 5 more

Test case is attached.

How to run: 
  $ java Test
Comments
RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v49_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v50_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v51_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/CovariantOverrides_v52_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v49_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v50_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v51_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/MethodResolution_v52_syncstrict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_none_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_none_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_strict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_strict_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_sync_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_sync_invoke_redefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_syncstrict_invoke_noredefine ExitCode 97 RULE vm/runtime/defmeth/scenarios/SuperCall_v52_syncstrict_invoke_redefine ExitCode 97
07-08-2013

Attached test case passes with the suggested fix for JDK-7087658. Closing as a duplicate.
03-07-2013

Possible dup of JDK-7087658. Checking...
01-07-2013

Thanks. I think this is something for John.
21-06-2013

It s unclear to me where jsr292 issues should be filed to get the right attention - so added Christian to the watch list.
21-06-2013