JDK-8068517 : Compiler may generate wrong InnerClasses attribute for static enum reference
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-01-06
  • Updated: 2016-02-15
  • Resolved: 2015-01-16
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
8u60Fixed 9 b47Fixed
Related Reports
Duplicate :  
Description
For implicitly abstract nested enums, the InnerClasses attribute may be wrong depending on the order of compilation of files.
Comments
If the referring enums are in different package, a possible workaround could be to refer the enum using static import first.
15-02-2016

Appears to be an interaction between the time the InnerClasses classfile attribute is generated and the time an enum is marked abstract. Attached is a test case, which compiles two files in different orders, leading to different value of the InnerClasses attribute. To show the problem, consider these two files: A.java: --- class A { enum AInner implements Runnable { A { public void run() {} }; } } --- B.java --- public class B { A.AInner a; } --- Note that the B's InnerClasses attribute will contain reference to A.AInner. Depending on the order of processing of the files, the InnerClasses attribute may say that A.AInner is an abstract class (correct), or say it is not abstract (incorrect). The problem is that the abstract flag for the enum is added in the attribute phase (in Check.checkAllDefined). So if B.class is generated before A goes through attribute, B's InnerClasses attribute won't be correct. If A goes through attribute before B.class is generated, B's InnerClasses attribute will be correct. A potential workaround would be to use "-XDcompilePolicy=simple" javac option - that should ensure all classes are attributed before generating any classfile, at the cost of higher memory consumption/slower processing.
06-01-2015