JDK-8031045 : Access checks should precede additional per-instruction checks
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs25,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-12-25
  • Updated: 2014-10-04
  • Resolved: 2014-01-23
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 JDK 9
8u20 b01Fixed 9Fixed
Related Reports
Relates :  
Description
Consider the following case:
  public interface I1 { private static void m() {} }
  public class T2 implements I1 { }

Call site: T2 { invokeinterface I1.m()V T2; }

There are 2 inconsistencies here:
   - I1.m isn't accessible to T2
   - invokeinterface doesn't accept static methods

VM behavior: IncompatibleClassChangeError: Expected instance not static method p1.I2.m()I

JVMS: IllegalAccessError: tried to access method p1.I2.m()I from class p1.T3

My reading of the spec is that the checks during method resolution [1] should precede additional instruction-specific check [2].

[1] 5.4.3.3. Method Resolution.
"Otherwise, if method lookup succeeds but the referenced method is not accessible (��5.4.4) to D, method resolution throws an IllegalAccessError."

[2] 6.5. invokespecial
"Linking Exceptions

During resolution of the symbolic reference to the method, any of the exceptions pertaining to method resolution (��5.4.3.3) can be thrown.
...
Otherwise, if the resolved method is a class (static) method, the invokespecial instruction throws an IncompatibleClassChangeError."

ILW = HLM = P3

I = H = JVMS violation; though error mismatch isn't that serious, it adds noise into the results and hinders results analysis of default method security testing  
L = L = forbidden by JLS, but separate compilation may be a source of that
W = M = Incorrect exception can be "translated" if necessary
Comments
TestReabstractStatic.java is for bug JDK-8031096. Bug 8031096 has the same symptoms as this bug but the cause is different. The correct test for this bug is TestIAE.java.
16-01-2014

TestReabstractStatic.java: testcase for ICCE vs AME case.
27-12-2013

Similar situation with ICCE vs AME for invokestatic: public interface I1 { default public void m() {}} public interface I2 extends I1 { public void m(); } public class T3 implements I2 {} Call site: T3 { invokestatic T3.m()V T3 } NB: T3 isn't marked as abstract. VM: IncompatibleClassChangeError: Expected static method p1.T3.m()I JVMS: AbstractMethodError should be thrown Please, note that if I1.m is absent, AME is thrown as expected. JVMS-5.4.3.3. Method Resolution "[I]f method lookup succeeds and the method is abstract, but C is not abstract, method resolution throws an AbstractMethodError." JVMS-6.5 invokestatic. "Linking Exceptions During resolution of the symbolic reference to the method, any of the exceptions pertaining to method resolution (��5.4.3.3) can be thrown. Otherwise, if the resolved method is an instance method, the invokestatic instruction throws an IncompatibleClassChangeError."
26-12-2013

I wouldn't rate Workaround as Low if program's source code changes are required. At least, it's Medium.
26-12-2013

Discovered during default methods security assessment
26-12-2013