JDK-8016320 : Method reference in subinterface of type I.super::foo produces exception at runtime
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-06-11
  • Updated: 2014-04-11
  • Resolved: 2013-10-11
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 8
8 b113Fixed
Related Reports
Blocks :  
Relates :  
Description
Java produces the following Exception at runtime:

Exception in thread "main" java.lang.ClassFormatError: Method lambda$0$bridge in class x/T has illegal modifiers: 0x1000

Testcase:

package x;

interface SAM {
    int m();
}

interface SuperI {
    public default int foo() { return 0; }
}

interface I extends SuperI {
}

interface T extends I {
    public default void boo() { SAM s = I.super::foo; }
}

public class lmbd04804m0  {
    public static void main(String argv[]) {
        new T(){};
    }
}
Comments
As expected, still reproduces. The "private" fixes are coming down the pike.
01-10-2013

Please set it to PUBLIC until private interface methods are supported.
26-08-2013

The VM code expects exactly on of ACC_PUBLIC and ACC_PRIVATE to be set. This was based on the following. ------ http://cr.openjdk.java.net/~dlsmith/jsr335-0.6.2.html#J says Methods of interfaces may set any of the flags in Table 4.5 except ACC_PROTECTED, ACC_FINAL, ACC_NATIVE, and ACC_SYNCHRONIZED (9.4); they must have exactly one of the ACC_PUBLIC or ACC_PRIVATE flags set. ------- T is an interface and int lambda$0$bridge() does not specify either of ACC_PRIVATE or ACC_PUBLIC
26-08-2013

We can certainly update the compiler to set the PRIVATE bit on this method. That's an easy fix. Separately, we should consider what the spec *should* say, and then adjust the VM to be consistent with that.
26-08-2013

Here's the specified behavior: ACC_SYNTHETIC was allowed in 7, and has not been prohibited in 8. "All interface methods must have their ACC_ABSTRACT and ACC_PUBLIC flags set; they may have their ACC_VARARGS, ACC_BRIDGE and ACC_SYNTHETIC flags set and must not have any of the other flags in Table 4.5 set (JLS ��9.4)." http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6
21-08-2013

javap output: int lambda$0$bridge(); descriptor: ()I flags: ACC_SYNTHETIC Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #2 // InterfaceMethod I.foo:()I 4: ireturn LineNumberTable: line 13: 0 It appears that it is the SYNTHETIC flag appearing on an interface method that the VM is complaining about?
21-08-2013

The following tests are also affected: lang/LMBD/lmbd073/lmbd07302m11/lmbd07302m11.html lang/LMBD/lmbd073/lmbd07302m2/lmbd07302m2.html RULE lang/LMBD/lmbd073/lmbd07302m11/lmbd07302m11_rt Exception java.lang.ClassFormatError RULE lang/LMBD/lmbd073/lmbd07302m2/lmbd07302m2_rt Exception java.lang.ClassFormatError
30-07-2013

The following JCK tests were added for this case: lang/LMBD/lmbd048/lmbd04803m0/lmbd04803m0.html lang/LMBD/lmbd048/lmbd04803m01/lmbd04803m01.html RULE lang/LMBD/lmbd048/lmbd04803m0/lmbd04803m0_rt Exception java.lang.ClassFormatError RULE lang/LMBD/lmbd048/lmbd04803m01/lmbd04803m01_rt Exception java.lang.ClassFormatError
30-07-2013

Reproduces with latest TL
22-07-2013

RULE lang/LMBD/lmbd048/lmbd04803m0/lmbd04803m0 any any RULE lang/LMBD/lmbd048/lmbd04803m01/lmbd04803m01 any any RULE lang/LMBD/lmbd073/lmbd07302m11/lmbd07302m11 any any RULE lang/LMBD/lmbd073/lmbd07302m2/lmbd07302m2 any any
18-07-2013

Yes reproducible with b92 and b93
11-06-2013