JDK-8055917 : jdk.nashorn.internal.codegen.CompilationPhase$N should be renamed to proper classes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-08-25
  • Updated: 2016-01-14
  • Resolved: 2015-09-14
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
8u72Fixed 9 b83Fixed
Description
Current strategy of providing the CompilationPhases straight in the enum fires back when you look at the profiles, when you see these "distinct" versions:

jdk.nashorn.internal.codegen.CompilationPhase$1.transform
jdk.nashorn.internal.codegen.CompilationPhase$2.transform
jdk.nashorn.internal.codegen.CompilationPhase$3.transform
jdk.nashorn.internal.codegen.CompilationPhase$4.transform
jdk.nashorn.internal.codegen.CompilationPhase$5.transform
jdk.nashorn.internal.codegen.CompilationPhase$6.transform
jdk.nashorn.internal.codegen.CompilationPhase$7.transform
jdk.nashorn.internal.codegen.CompilationPhase$8.transform
jdk.nashorn.internal.codegen.CompilationPhase$9.transform
jdk.nashorn.internal.codegen.CompilationPhase$10.transform
jdk.nashorn.internal.codegen.CompilationPhase$11.transform
jdk.nashorn.internal.codegen.CompilationPhase$12.transform

Naming these classes properly should help to get more understandable profiles -- that probably explodes the CompilationPhase implementations from the enum into the top-level classes.
Comments
What's the point of having CompilationPhase as Enum -- tracking dependencies? You can probably have a separate enum without implementations, and then maintain Map<CompilationPhaseType, CompilationPhase>, where CompilationPhaseType is an enum without an implementation, and CompilationPhase is a proper interface.
05-11-2014

We can fake it by doing something horrible like calling the transform method of each element "transformNameOfTransform" and looking it up by reflection. Then a stack trace would always be able to tell you what's going on, but it's horrible :) /M
05-11-2014

Ah, that might be not doable without pushing javac to produce human-readable class names (and that might collide with some spec provision). It might be worthwhile to explode CompilationPhase to a proper interface?
25-08-2014