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.38k stars 1.64k forks source link

NPE in com.oracle.truffle.runtime.hotspot.HotSpotTruffleRuntimeAccess.createRuntime(): "jdk.internal.module.Modules.JLA" is null #9491

Open novos40 opened 2 months ago

novos40 commented 2 months ago

Describe GraalVM and your environment :

Have you verified this issue still happens when using the latest snapshot? No. Using stable version v24.0.2

Describe the issue I have built polyglot OSGi bundle with python support to run on apache felix OSGi container. The goal is to run python on java. Everything was working with v23.1.1. Now I'm getting NPE

Expected behavior Correct initialization or at least meaningful diagnostic

Additional context Was working on JDK-17 and v23.1.1 with -Dpolyglotimpl.TraceClassPathIsolation=true -Dpolyglotimpl.DisableClassPathIsolation=true

I was having problems with native python libraries loading (another issue). I was hoping that latest polyglot version would resolve that. It looks like something is not initialized correctly. (i.e. "jdk.internal.module.Modules.JLA" is null)

OSGi container uses org.apache.atomos to load all JDK modules. They are correctly loaded and exposed as bundles. Everything works except polyglot initialization.

Details Caused by: java.lang.ExceptionInInitializerError at com.oracle.truffle.runtime.hotspot.HotSpotTruffleRuntimeAccess.createRuntime(HotSpotTruffleRuntimeAccess.java:84) at com.oracle.truffle.runtime.hotspot.HotSpotTruffleRuntimeAccess.getRuntime(HotSpotTruffleRuntimeAccess.java:75) at com.oracle.truffle.api.Truffle.createRuntime(Truffle.java:145) at com.oracle.truffle.api.Truffle$1.run(Truffle.java:176) at com.oracle.truffle.api.Truffle$1.run(Truffle.java:174) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at com.oracle.truffle.api.Truffle.initRuntime(Truffle.java:174) at com.oracle.truffle.api.Truffle.(Truffle.java:63) at com.oracle.truffle.runtime.enterprise.EnterpriseTruffle.supportsEnterpriseExtensions(stripped:21) at com.oracle.truffle.polyglot.enterprise.EnterprisePolyglotImpl.getPriority(stripped:518) at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473) at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) at java.base/java.util.TimSort.sort(TimSort.java:220) at java.base/java.util.Arrays.sort(Arrays.java:1308) at java.base/java.util.ArrayList.sort(ArrayList.java:1804) at java.base/java.util.Collections.sort(Collections.java:178) at org.graalvm.polyglot.Engine.loadAndValidateProviders(Engine.java:1656) at org.graalvm.polyglot.Engine$1.run(Engine.java:1732) at org.graalvm.polyglot.Engine$1.run(Engine.java:1727) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1727) at org.graalvm.polyglot.Engine$ImplHolder.(Engine.java:190) at org.graalvm.polyglot.Engine.getImpl(Engine.java:442) at org.graalvm.polyglot.Engine$Builder.build(Engine.java:740) ... Caused by: java.lang.NullPointerException: Cannot invoke "jdk.internal.access.JavaLangAccess.addExports(java.lang.Module, String, java.lang.Module)" because "jdk.internal.module.Modules.JLA" is null at jdk.internal.module.Modules.addExports(Modules.java:105) at com.oracle.truffle.runtime.ModulesSupport.addExports0(Native Method) at com.oracle.truffle.runtime.ModulesSupport.(ModulesSupport.java:69) ... 125 more
novos40 commented 2 months ago

I was able to make it work by collecting all relevant jars (using maven's dependency:copy-dependencies) and placing them all on the module path. This works for both OpenJDK and graalvm JDK. I still think this should be fixed as I should be able to collect all modules into a single jar and run it off the class path (with -Dpolyglotimpl.DisableClassPathIsolation=true or some other relevant settings). One of the main points of using OSGi is the ability to create per-feature bundle/jar and enable that feature for a particular deployment by simply placing the jar into a bundle folder. Now instead of a single bundle jar I'd have to manage 31 module jars to enable this single feature of running python code in our container.