oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.28k stars 1.63k forks source link

espresso NullPointerException when running on native image #3665

Open Nightloewe opened 3 years ago

Nightloewe commented 3 years ago

Describe GraalVM and your environment :

Have you verified this issue still happens when using the latest snapshot? No You can find snapshot builds here: https://github.com/graalvm/graalvm-ce-dev-builds/releases

Describe the issue A NullPointerException happens when trying to start a native image using Espresso.

Code snippet or code repository that reproduces the issue

https://github.com/Nightloewe/NativeTest

Steps to reproduce the issue Please include both build steps as well as run steps

  1. git clone https://github.com/Nightloewe/NativeTest
  2. Run mvn clean install in plugin_api sub directory
  3. Run mvn -Pnative -DskipTests package in root directory of the project
  4. Copy native_test.exe from target sub directory into root directory of the project
  5. Run native_test.exe -Djava.home=%JAVA_HOME% with %JAVA_HOME% being the location of the graalvm installation

Expected behavior The Context is built without any exception to happen.

Additional context Add any other context about the problem here. Specially important are stack traces or log output. Feel free to link to gists or to screenshots if necesary

Details ``` org.graalvm.polyglot.PolyglotException: java.lang.NullPointerException at com.oracle.truffle.espresso.runtime.EspressoProperties.processOptions(EspressoProperties.java:293) ~[na:na] at com.oracle.truffle.espresso.runtime.EspressoContext.initVmProperties(EspressoContext.java:616) ~[na:na] at com.oracle.truffle.espresso.runtime.EspressoContext.spawnVM(EspressoContext.java:450) ~[na:na] at com.oracle.truffle.espresso.runtime.EspressoContext.initializeContext(EspressoContext.java:410) ~[na:na] at com.oracle.truffle.espresso.EspressoLanguage.initializeContext(EspressoLanguage.java:143) ~[na:na] at com.oracle.truffle.espresso.EspressoLanguage.initializeContext(EspressoLanguage.java:63) ~[na:na] at com.oracle.truffle.api.TruffleLanguage$Env.postInit(TruffleLanguage.java:3640) ~[na:na] at com.oracle.truffle.api.LanguageAccessor$LanguageImpl.postInitEnv(LanguageAccessor.java:300) ~[na:na] at com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureInitialized(PolyglotLanguageContext.java:638) ~[na:na] at com.oracle.truffle.polyglot.PolyglotContextImpl.getBindings(PolyglotContextImpl.java:1104) ~[na:na] at com.oracle.truffle.polyglot.PolyglotContextDispatch.getBindings(PolyglotContextDispatch.java:97) ~[na:na] at org.graalvm.polyglot.Context.getBindings(Context.java:536) ~[na:na] at dev.teamnight.native_test.NativeTestApplication.onApplicationEvent(NativeTestApplication.java:45) ~[native_test.exe:0.0.1-SNAPSHOT] at dev.teamnight.native_test.NativeTestApplication.onApplicationEvent(NativeTestApplication.java:14) ~[native_test.exe:0.0.1-SNAPSHOT] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) ~[na:na] at org.springframework.boot.context.event.EventPublishingRunListener.contextPrepared(EventPublishingRunListener.java:89) ~[native_test.exe:2.5.3] at org.springframework.boot.SpringApplicationRunListeners.lambda$contextPrepared$3(SpringApplicationRunListeners.java:67) ~[na:na] at java.util.ArrayList.forEach(ArrayList.java:1541) ~[native_test.exe:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.contextPrepared(SpringApplicationRunListeners.java:67) ~[na:na] at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:404) ~[native_test.exe:2.5.3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:337) ~[native_test.exe:2.5.3] at dev.teamnight.native_test.NativeTestApplication.main(NativeTestApplication.java:20) ~[native_test.exe:0.0.1-SNAPSHOT] ```
Nightloewe commented 3 years ago

I got it working by also setting System.setProperty("org.graalvm.home", javaHome);, cause the method org.graalvm.home.impl.DefaultHomeFinder#getGraalVmHomeNative() returns null

fernando-valdez commented 3 years ago

Hello @Nightloewe, I am going to take a look at this issue. If I have any questions I will let you know