JDK-8009130 : JCK lambda test fails with IllegalAccessException
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs25
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-02-27
  • Updated: 2014-01-14
  • Resolved: 2013-10-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 8 Other
8Fixed hs25Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
package p1;

interface Sup {
default void m();
}

public interface Sub extends Sup { }

package p2;

class Foo implements p1.Sub { }

Foo foo = new Foo();
foo.m(); //IllegalAccessError at runtime

Comments
For DKFL: RULE lang/CLSS/clss475/clss47501m21/clss47501m21 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.clss475.clss47501m21.pack2.SuperInterface2 from class javasoft.sqe.tests.lang.clss475.clss47501m21.ACls RULE lang/CLSS/clss475/clss47501m211/clss47501m211 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.clss475.clss47501m211.pack2.SuperInterface2 from class javasoft.sqe.tests.lang.clss475.clss47501m211.ACls RULE lang/INTF/intf024/intf02402m01/intf02402m01 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.intf024.intf02402m01.subp2.SubIntf from class javasoft.sqe.tests.lang.intf024.intf02402m01.subp1.PubCls RULE lang/INTF/intf024/intf02402m11/intf02402m11 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.intf024.intf02402m11.subp2.SubIntf from class javasoft.sqe.tests.lang.intf024.intf02402m11.subp1.PubCls RULE lang/LMBD/lmbd140/lmbd14004m201/lmbd14004m201 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.lmbd140.lmbd14004m201.anotherpkg.MethodSupplier from class javasoft.sqe.tests.lang.lmbd140.lmbd14004m201.MethodInvoker RULE lang/LMBD/lmbd140/lmbd14004m201/lmbd14004m201 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14004m3111/lmbd14004m3111 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.lmbd140.lmbd14004m3111.anotherpkg.MethodSupplier from class javasoft.sqe.tests.lang.lmbd140.lmbd14004m3111.MethodInvoker RULE lang/LMBD/lmbd140/lmbd14004m3111/lmbd14004m3111 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14007m0021/lmbd14007m0021 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.lmbd140.lmbd14007m0021.anotherpkg.MethodSupplierOuter$MethodSupplier from class javasoft.sqe.tests.lang.lmbd140.lmbd14007m0021.MethodInvoker RULE lang/LMBD/lmbd140/lmbd14007m0021/lmbd14007m0021 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14007m11211/lmbd14007m11211 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd140.lmbd14007m11211.anotherpkg.MethodSupplierOuter$MethodSupplier.<init>()V from class javasoft.sqe.tests.lang.lmbd140.lmbd14007m11211.anotherpkg.MethodSupplierFactory RULE lang/LMBD/lmbd140/lmbd14007m11211/lmbd14007m11211 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14007m21111/lmbd14007m21111 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd140.lmbd14007m21111.anotherpkg.MethodSupplierOuter$MethodSupplier.<init>()V from class javasoft.sqe.tests.lang.lmbd140.lmbd14007m21111.MethodInvoker RULE lang/LMBD/lmbd140/lmbd14007m21111/lmbd14007m21111 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14007m302/lmbd14007m302 Exception java.lang.IllegalAccessError: tried to access class javasoft.sqe.tests.lang.lmbd140.lmbd14007m302.anotherpkg.MethodSupplierOuter$MethodSupplier from class javasoft.sqe.tests.lang.lmbd140.lmbd14007m302.MethodInvoker RULE lang/LMBD/lmbd140/lmbd14007m302/lmbd14007m302 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14007m31011/lmbd14007m31011 Exception java.lang.IllegalAccessException: member is protected: javasoft.sqe.tests.lang.lmbd140.lmbd14007m31011.anotherpkg.MethodSupplierOuter$MethodSupplier.m(int,String,long)String/invokeVirtual, from javasoft.sqe.tests.lang.lmbd140.lmbd14007m31011.MethodInvoker RULE lang/LMBD/lmbd140/lmbd14007m31011/lmbd14007m31011 Exception java.lang.IncompatibleClassChangeError RULE lang/LMBD/lmbd140/lmbd14007m31011/lmbd14007m31011 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd140/lmbd14007m41201/lmbd14007m41201 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd140.lmbd14007m41201.anotherpkg.MethodSupplierOuter$MethodSupplier.<init>()V from class javasoft.sqe.tests.lang.lmbd140.lmbd14007m41201.anotherpkg.MethodSupplierFactory RULE lang/LMBD/lmbd140/lmbd14007m41201/lmbd14007m41201 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14503m0002/lmbd14503m0002 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14503m0002.MethodSupplier.m(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14503m0002.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14503m0002/lmbd14503m0002 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14504m0002/lmbd14504m0002 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14504m0002.anotherpkg.MethodSupplier.m(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14504m0002.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14504m0002/lmbd14504m0002 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14504m1103/lmbd14504m1103 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14504m1103.anotherpkg.MethodSupplier.m(ILjava/lang/String;J)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14504m1103.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14504m1103/lmbd14504m1103 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14505m0002/lmbd14505m0002 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14505m0002.anotherpkg.MethodSupplierOuter$MethodSupplier.m(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14505m0002.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14505m0002/lmbd14505m0002 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14505m0012/lmbd14505m0012 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14505m0012.anotherpkg.MethodSupplierOuter$MethodSupplier.m(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14505m0012.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14505m0012/lmbd14505m0012 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14505m11021/lmbd14505m11021 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14505m11021.anotherpkg.MethodSupplierOuter$MethodSupplier.m(ILjava/lang/String;J)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14505m11021.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14505m11021/lmbd14505m11021 Exception java.lang.reflect.InvocationTargetException RULE lang/LMBD/lmbd145/lmbd14505m11121/lmbd14505m11121 Exception java.lang.IllegalAccessError: tried to access method javasoft.sqe.tests.lang.lmbd145.lmbd14505m11121.anotherpkg.MethodSupplierOuter$MethodSupplier.m(ILjava/lang/String;J)Ljava/lang/String; from class javasoft.sqe.tests.lang.lmbd145.lmbd14505m11121.MethodInvoker RULE lang/LMBD/lmbd145/lmbd14505m11121/lmbd14505m11121 Exception java.lang.reflect.InvocationTargetException Logs (JDK 8 b109 + JCK 8 b30): http://aurora.ru.oracle.com/functional/faces/RunDetails.xhtml?names=294869.ute.st2-1
03-10-2013

RULE lang/INTF/intf024/intf02402m01/intf02402m01_rt Exception java.lang.IllegalAccessError RULE lang/INTF/intf024/intf02402m11/intf02402m11_rt Exception java.lang.IllegalAccessError
24-09-2013

Prototype fix for this appears to also fix the following: jck8 test of api/java_util/TreeSet/ParallelStream.html I hit an assert when doing CHA for a default method during JIT-compilation: # Internal Error (src/share/vm/code/dependencies.cpp:1411) # assert(wf.check_method_context(ctxk, m)) failed: proper context Call stack: Dependencies::find_unique_concrete_method ciMethod::find_monomorphic_target Compile::optimize_inlining Compile::optimize_virtual_call Parse::do_call
19-09-2013

After several prototypes, current proposal is to simplify how default methods are handled by 1) not using overpasses for default methods, not using a second step invokespecial - this removes the problem with invokespecial's constant pool lookup that requires class access 2) creating default_methods array in the inheriting instanceKlass with public default methods 3) search order: current class methods, super classes methods, default methods, transitive interfaces 4) adding the default method to the vtable directly, with the default method having the correct method holder, which allows the permission and loader constraint tests to work on the correct method holder/class loader 5) overpasses are still used for AME for conflicts with default methods, these are still added to the local method and constant pool (future potential for optimizations here)
22-08-2013

Now that we have agreed that the JVM is not generating bridges, and is not handling generic signatures and covariant returns, the JVM no longer needs to create overpass methods to contain the appropriate check casts. The fix is for the JVM to determine the appropriate default methods and to track those in inheriting class, and include them in the vtable inheritance, maintaining the original methods and the method-holder (i.e. the interface which defines the default method). This means that both the access checking and the loader constraint checking will be done against the correct method and method-holder, i.e. class. The JVM does create overpasses to handle the error conditions, for example if there are conflicting default methods, then we need a new method to enable us to throw the appropriate error and error message. Checking in the fix under this bug, which also fixes 80013085.
23-07-2013

A similar example to address; in this case, the VM-generated invokespecial instruction (in B) needs to refer to the superclass (A), not a superinterface. package p1; interface I { public default int m() { return 12; } } package p2; public interface J {} /* Note: unrelated to I */ package p1; public class A implements I {} package p2; public class B extends A implements J {}
23-04-2013

Adding test case names to have them matched in Aurora runs: lang/CLSS/clss475/clss47501m21/clss47501m21 lang/CLSS/clss475/clss47501m211/clss47501m211
23-04-2013

Suggested fix: change the code generated in each default method "overpass" so that it names a direct super of the current class, and leave it to resolution find the actual declaration. (Thanks to the 'implements' clause, we already know that the direct supers are accessible.)
22-04-2013

Two JCK8 tests failures seems to be related: lang/INTF/intf024/intf02402m01/intf02402m01.html lang/INTF/intf024/intf02402m11/intf02402m11.html
07-03-2013

The bridge is generated according to 6342411. It is _not_ related to overriding.
05-03-2013

I though maybe I'd missed something here, and the method really is accessible. I note that the javap output for the counterexample we're using includes a bridge method, which might explain why it doesn't produce the same error: package a; class A { public int m() { return 12; } } package a; public class B extends A { /* bridge goes here*/ } package b; public class C extends a.B {} System.out.println(new b.C().m()); --- public class a.B extends a.A { ... public int m(); flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #2 // Method a/A.m:()I 4: ireturn LineNumberTable: line 1: 0 } --- However, everything works fine if I replace B with an equivalent class that has no bridge. (Maybe the bridge serves some other purpose...?) Anyway, method resolution (JVMS 5.4.3.3) does specify an IAE, but only if the _named_ class is inaccessible or the _resolved_ method is inaccessible. The class/interface of the resolved method is irrelevant to this access check (see JVMS 5.4.4).
04-03-2013

Seems like an hotspot problem with default method calls - the following similar program compiles and runs without problems: package p1; class Sup { public void m() { } } public class Sub extends Sup { } package p2; class Foo extends p1.Sub { } Foo foo = new Foo(); foo.m(); //ok In both cases javac emits an invokevirtual to Foo.m().
27-02-2013