JDK-8033951 : nasgen needs the newly build nasgen and nashorn classes in the bootclasspath
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-02-07
  • Updated: 2014-07-29
  • Resolved: 2014-02-10
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.
8u20Fixed 9 b06Fixed
During the nashorn build, the nasgen tool is called as follows:

<boot_jdk>/bin/java \
  -Xms64M -Xmx1100M \
  -XX:PermSize=32m \
  -XX:MaxPermSize=160m \
  -XX:ThreadStackSize=1536 \
  -cp "<build_dir>/nashorn/nasgen_classes:<build_dir>/nashorn/nashorn_classes"\
  jdk.nashorn.internal.tools.nasgen.Main \
  <build_dir>/nashorn/classes jdk.nashorn.internal.objects <build_dir>/nashorn/classes

The problem is that the call puts the newly created nashorn and nasgen class (which also include the required asm class) into the class path. This will lead to problems, if the boot jdk contains different version of some of these classes.

Until now, this problem was seldom, because the jdk7 doens't contain any of these classes, so no conflicts could occur. But building a new version of jdk8/jdk9 with an older jdk8 build may lead to build errors like this:

/share/software/Java/jdk1.8.0_ea_b70/bin/java -Xms64M -Xmx1100M -XX:ThreadStackSize=1536 \
            -Xbootclasspath/p:"/tmp/jdk9-client-opt/nashorn/nasgen_classes" -cp "/tmp/jdk9-client-opt/nashorn/nashorn_classes" \
            jdk.nashorn.internal.tools.nasgen.Main /tmp/jdk9-client-opt/nashorn/classes jdk.nashorn.internal.objects /tmp/jdk9-client-opt/nashorn/classes
Exception in thread "main" java.lang.NoClassDefFoundError: jdk/nashorn/internal/objects/annotations/ScriptClass
        at jdk.nashorn.internal.tools.nasgen.ScriptClassInfo.<clinit>(ScriptClassInfo.java:52)
        at jdk.nashorn.internal.tools.nasgen.ScriptClassInfoCollector.visitAnnotation(ScriptClassInfoCollector.java:82)
        at jdk.internal.org.objectweb.asm.ClassReader.accept(ClassReader.java:670)
        at jdk.internal.org.objectweb.asm.ClassReader.accept(ClassReader.java:535)
        at jdk.nashorn.internal.tools.nasgen.ClassGenerator.getScriptClassInfo(ClassGenerator.java:370)
        at jdk.nashorn.internal.tools.nasgen.ClassGenerator.getScriptClassInfo(ClassGenerator.java:365)
        at jdk.nashorn.internal.tools.nasgen.Main.process(Main.java:104)
        at jdk.nashorn.internal.tools.nasgen.Main.processAll(Main.java:88)
        at jdk.nashorn.internal.tools.nasgen.Main.main(Main.java:62)
make[1]: *** [/tmp/jdk9-client-opt/nashorn/classes/_the.nasgen.run] Error 1
make[1]: Leaving directory `/net/usr.work/d046063/OpenJDK/jdk9-client/nashorn/make'

Also see the message "Compilation failure due to mismatching internal classes in the boot JDK" at http://mail.openjdk.java.net/pipermail/nashorn-dev/2014-January/002687.html

The fix for this is easy - just put the required classes in the boot class path instead just in the class path.