Openj9: MacOS: bootstrapping OpenJ9 JDK11 with OpenJ9 JDK11 fails with NPE

Created on 11 Dec 2018  路  10Comments  路  Source: eclipse/openj9

Steps to reproduce:

  1. Configure and build OpenJ9 using JDK10 as bootstrap JDK. Configure arguments: --with-freemarker-jar=/path/to/freemarker.jar --disable-warnings-as-errors --with-noncompressedrefs --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
  2. Copy the bundle somewhere
  3. Configure and build OpenJ9 using the JDK11 you just built. Configure arguments: --with-freemarker-jar=/path/to/freemarker.jar --disable-warnings-as-errors --with-noncompressedrefs --with-boot-jdk=/path/to/jdk-11.0.1.jdk/Contents/Home
  4. The following errors will appear:

Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
make[3]: * [/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon32_java_icon16_png.java] Error 1
make[3]:
Waiting for unfinished jobs....
make[3]:
[/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon32_java_icon24_png.java] Error 1
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
make[3]:
[/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon32_java_icon32_png.java] Error 1
Compiling 117 files for java.compiler
Compiling 18 files for java.datatransfer
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
make[3]:
[/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon64_java_icon32_png.java] Error 1
make[3]:
[/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon64_java_icon16_png.java] Error 1
Compiling 10 files for java.instrument
Compiling 34 files for java.logging
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:191)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:180)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:130)
at java.desktop/java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
at java.desktop/java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
at build.tools.icondata.awt.ToBin.main(ToBin.java:41)
Caused by: java.lang.NullPointerException
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:339)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:102)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:83)
... 4 more
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C sourcetools -f buildj9tools.mk FREEMARKER_JAR=/path/to/freemarker.jar
make[3]:
[/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon32_java_icon48_png.java] Error 1
make[3]:
[/path/to/openj9-openjdk-jdk11/build/macosx-x86_64-normal-server-release/support/gensrc/java.desktop/sun/awt//AWTIcon64_java_icon24_png.java] Error 1
make[2]: *
* [java.desktop-gensrc-src] Error 2

Tested on: MacOS 10.14.2, XCode 10.1.
Note: the same error was obtained with and without "--with-noncompressedrefs".

vm userRaised

Most helpful comment

@JasonFengJ9 it worked with your PR!

All 10 comments

@pdbain-ibm FYI.

I've checked the implementation of Class.forNameImpl and it will only throw a NPE if the class name is null. This parameter comes straight from the invocation to forName(). In this case, it comes from reading a property named "java.awt.graphicsenv", which in this case is null.

So, in GraphicsEnvironment.java, line 93, variable "nm" is turning out to be null. That's as far as I could get with this.

FYI @JasonFengJ9 @pshipton

This appears another missing case for MacOS.

#ifdef J9VM_UNIX
    if (J9SYSPROP_ERROR_NOT_FOUND == vmfunc->getSystemProperty(javaVM, "java.awt.graphicsenv", NULL)) {
        rc = vmfunc->addSystemProperty(javaVM, "java.awt.graphicsenv", "sun.awt.X11GraphicsEnvironment", 0);
        if (J9SYSPROP_ERROR_NONE != rc) {
            return rc;
        }
    }

System property awt.toolkit is missing at MacOS as well.

It seems that the correct value for "java.awt.graphicsenv" is sun.awt.CGraphicsEnvironment. But for "awt.toolkit" I'm not 100% sure, but the correct value seems to be "sun.lwawt.macosx.LWCToolkit"

That's correct according to Oracle Mac JDK11+28.

java version "11" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11+28)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)

java.awt.graphicsenv = sun.awt.CGraphicsEnvironment
awt.toolkit = sun.lwawt.macosx.LWCToolkit

@sergioag just realize that you made a PR for this issue as well. Probably I should make a note that I am working on this. Feel free to give PR #3998 a try.

@JasonFengJ9 don't worry. Yours is much better than mine anyway :) Will try and report.

@JasonFengJ9 it worked with your PR!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsimomaa picture jsimomaa  路  109Comments

dcendents picture dcendents  路  53Comments

lmajewski picture lmajewski  路  123Comments

fjeremic picture fjeremic  路  62Comments

Thihup picture Thihup  路  51Comments