JDK-8027789 : Access method for Outer.super.m() references indirect superclass
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7u45,8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-11-04
  • Updated: 2017-05-17
  • Resolved: 2013-11-26
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 b119Fixed
Related Reports
Relates :  
Description
When an invocation of the form Outer.super.m() refers to a protected method in an indirect superclass, the compiler generates an access bridge method.  But the generated invokespecial in this method's body incorrectly qualifies the reference with the indirect superclass, not the direct superclass.

Test:

---
package p1;
/* package-access */ class A {
  protected void m() {}
}
---
package p1;
public class B extends A {}
---
package p2;
public class C extends p1.B {
  { new Object() { { C.super.m(); } }; }
}
---
public class Test {
  public static void main(String... args) { new p2.C(); }
}
---

Compiles without error, as expected.

Expected runtime behavior: run without error

Actual runtime behavior:
Exception in thread "main" java.lang.IllegalAccessError: tried to access class p1.A from class p2.C
	at p2.C.access$001(C.java:2)
	at p2.C$1.<init>(C.java:3)
	at p2.C.<init>(C.java:3)
	at Test.main(Test.java:2)

javap output for p2.C.access$001
  static void access$001(p2.C);
    descriptor: (Lp2/C;)V
    flags: ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0       
         1: invokespecial #1                  // Method p1/A.m:()V
         4: return        

The invokespecial should refer to p1/B.m:()V.
Comments
Release team: Approved for fixing
25-11-2013

SQE: OK to fix in 8
25-11-2013

8-critical-request justification: A valid Java program (as the one in the description) may not run correctly. The classfile produced by javac does not conform to JLS 13.1. Risk Assessment: Low risk. The fix is fairly limited, and only ensures the existing facilities for generating superclass access are used when the access methods are used. Level of testing coverage: Bootcycle JDK build, JCK tests, langtools jtreg tests ran. Built qualitas corpus with and without this fix, inspected differences. Size of fix: 2 files with non-test changes ~15 LOC, total (including tests): ~300 LOC, 5 files. Patch: http://cr.openjdk.java.net/~jlahoda/8027789/webrev.04/
22-11-2013