[GR-65207] [Native Image] [Tool SVM:WASM]
Describe the Issue
When trying out the graalvm-demos/native-image/build-with-js-embedded demo with --tool:svm-wasm, the build fails with the following exception:
Error: Feature defined by com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompilationFeature unexpectedly failed with a(n) java.lang.NullPointerException. Please report this problem to the authors of com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompilationFeature.
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.ListIterator.set(Object)" because the return value of "jdk.graal.compiler.phases.PhaseSuite.findPhase(java.lang.Class)" is null
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.modifySuites(NativeImageGenerator.java:1553)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.createSuites(NativeImageGenerator.java:1498)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.createSuites(NativeImageGenerator.java:1502)
at org.graalvm.nativeimage.builder/com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompilationFeature.installRuntimeConfig(RuntimeCompilationFeature.java:408)
at org.graalvm.nativeimage.builder/com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompilationFeature.beforeAnalysis(RuntimeCompilationFeature.java:420)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$0(NativeImageGenerator.java:808)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:93)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:808)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:567)
at org.graalvm.extraimage.builder/com.oracle.svm.hosted.aotjs.t.doRun(stripped:116)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:533)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:545)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:732)
at org.graalvm.extraimage.builder/com.oracle.svm.hosted.aotjs.l.build(stripped:194)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:151)
at org.graalvm.extraimage.builder/com.oracle.svm.hosted.aotjs.l.e(stripped:91)
at org.graalvm.extraimage.builder/com.oracle.svm.hosted.aotjs.m.run(stripped:42)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:105)
Using the latest version of GraalVM can resolve many issues.
- [x] I tried with the latest version of GraalVM.
GraalVM Version
java 24 2025-03-18 Java(TM) SE Runtime Environment Oracle GraalVM 24+36.1 (build 24+36-jvmci-b01) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 24+36.1 (build 24+36-jvmci-b01, mixed mode, sharing)
Operating System and Version
Linux Cliente 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build Command
native-image -cp /home/thihup/workspace/graalvm-demos/native-image/build-with-js-embedded/target/PrettyPrintJSON-1.0-SNAPSHOT.jar:/home/thihup/.m2/repository/org/graalvm/polyglot/polyglot/24.2.0/polyglot-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/sdk/collections/24.2.0/collections-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/sdk/nativeimage/24.2.0/nativeimage-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/sdk/word/24.2.0/word-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/js/js-language/24.2.0/js-language-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/regex/regex/24.2.0/regex-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/truffle/truffle-api/24.2.0/truffle-api-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/shadowed/icu4j/24.2.0/icu4j-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/shadowed/xz/24.2.0/xz-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/truffle/truffle-runtime/24.2.0/truffle-runtime-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/truffle/truffle-enterprise/24.2.0/truffle-enterprise-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/truffle/truffle-compiler/24.2.0/truffle-compiler-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/sdk/jniutils/24.2.0/jniutils-24.2.0.jar:/home/thihup/.m2/repository/org/graalvm/sdk/nativebridge/24.2.0/nativebridge-24.2.0.jar --no-fallback -o /home/thihup/workspace/graalvm-demos/native-image/build-with-js-embedded/target/PrettyPrintJSON --tool:svm-wasm com.example.PrettyPrintJSON returned non-zero result
Expected Behavior
Build successfully, as without the --tool:svm-wasm it works just fine.
Actual Behavior
The exception above
Steps to Reproduce
- Add <buildArgs><buildArg>--tool:svm-wasm</buildArg></buildArgs> to the pom.xml
- mvn package -Pnative
Additional Context
No response
Build Log Output and Error Messages
No response
Hey Thiago, thanks for reporting. We're tracking this internally under GR-63799.
Polyglot for JS probably won't work even if we get this to compile, but it should at least compile and produce an error at runtime.
Adding the -Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime property, the error changes.
[2/8] Performing analysis... [] (26.0s @ 1.63GB)
11,334 reachable types (84.6% of 13,394 total)
18,778 reachable fields (50.6% of 37,112 total)
56,000 reachable methods (58.7% of 95,362 total)
3,661 types, 73 fields, and 834 methods registered for reflection
Error: ImageSingletons do not contain key com.oracle.svm.core.os.AbstractRawFileOperationSupport$RawFileOperationSupportHolder
------------------------------------------------------------------------------------------------------------------------
2.8s (8.1% of total time) in 360 GCs | Peak RSS: 2.52GB | CPU load: 8.48
========================================================================================================================
Failed generating 'PrettyPrintJSON' after 33.9s.
com.oracle.svm.driver.NativeImage$NativeImageError
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.showError(NativeImage.java:2474)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:2056)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:2015)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1997)
at java.base@25/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)