graalvm / graal-js-jdk11-maven-demo

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
Universal Permissive License v1.0
177 stars 63 forks source link

What am I doing incorrectly? #34

Closed rhwood closed 4 years ago

rhwood commented 4 years ago

When I follow the Setup steps in README.md, I get this result:

rhwood@Calculus Developer % git clone https://github.com/graalvm/graal-js-jdk11-maven-demo
Cloning into 'graal-js-jdk11-maven-demo'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 422 (delta 6), reused 9 (delta 5), pack-reused 410
Receiving objects: 100% (422/422), 55.22 KiB | 3.07 MiB/s, done.
Resolving deltas: 100% (150/150), done.
rhwood@Calculus Developer % cd graal-js-jdk11-maven-demo
rhwood@Calculus graal-js-jdk11-maven-demo % export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home 
rhwood@Calculus graal-js-jdk11-maven-demo % mvn package
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/rhwood/Developer/graal-js-jdk11-maven-demo/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/rhwood/Developer/graal-js-jdk11-maven-demo/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/rhwood/Developer/graal-js-jdk11-maven-demo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ my-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/rhwood/Developer/graal-js-jdk11-maven-demo/target/test-classes
[INFO] 
[INFO] --- maven-dependency-plugin:2.10:copy (copy) @ my-app ---
[INFO] Configured Artifact: org.graalvm.compiler:compiler:20.0.0:jar
[INFO] Configured Artifact: org.graalvm.truffle:truffle-api:20.0.0:jar
[INFO] Configured Artifact: org.graalvm.sdk:graal-sdk:20.0.0:jar
[INFO] Copying compiler-20.0.0.jar to /Users/rhwood/Developer/graal-js-jdk11-maven-demo/target/compiler/compiler.jar
[INFO] Copying truffle-api-20.0.0.jar to /Users/rhwood/Developer/graal-js-jdk11-maven-demo/target/compiler/truffle-api.jar
[INFO] Copying graal-sdk-20.0.0.jar to /Users/rhwood/Developer/graal-js-jdk11-maven-demo/target/compiler/graal-sdk.jar
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ my-app ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.mycompany.app.AppTest
=== Nashorn via javax.script.ScriptEngine ===
Warning: Nashorn engine is planned to be removed from a future JDK release
warming up ...
warmup finished, now measuring
iteration: 217
iteration: 217
iteration: 215
iteration: 214
iteration: 213
iteration: 220
iteration: 217
iteration: 215
iteration: 215
iteration: 223
=== Graal.js via org.graalvm.polyglot.Context === 
=== Graal.js via javax.script.ScriptEngine ===
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 7.447 s <<< FAILURE! - in com.mycompany.app.AppTest
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest)  Time elapsed: 0.356 s  <<< ERROR!
org.graalvm.polyglot.PolyglotException: java.lang.AbstractMethodError: Receiver class org.graalvm.compiler.hotspot.management.HotSpotGraalManagement does not define or inherit an implementation of the resolved method 'abstract void initialize(org.graalvm.compiler.hotspot.HotSpotGraalRuntime, org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)' of interface org.graalvm.compiler.hotspot.HotSpotGraalManagementRegistration.

[ERROR] testGraalScriptEngineSpeed(com.mycompany.app.AppTest)  Time elapsed: 0.02 s  <<< ERROR!
java.lang.AbstractMethodError: Receiver class org.graalvm.compiler.hotspot.management.HotSpotGraalManagement does not define or inherit an implementation of the resolved method 'abstract void initialize(org.graalvm.compiler.hotspot.HotSpotGraalRuntime, org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)' of interface org.graalvm.compiler.hotspot.HotSpotGraalManagementRegistration.
Caused by: com.oracle.truffle.api.TruffleStackTrace$LazyStackTrace

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   AppTest.testGraalPolyglotSpeed » Polyglot java.lang.AbstractMethodError: Recei...
[ERROR]   AppTest.testGraalScriptEngineSpeed » AbstractMethod Receiver class org.graalvm...
[INFO] 
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.219 s
[INFO] Finished at: 2020-05-24T12:46:33-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project my-app: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/rhwood/Developer/graal-js-jdk11-maven-demo/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
rhwood@Calculus graal-js-jdk11-maven-demo % 

What step have I missed?

wirthi commented 4 years ago

Hi @rhwood

that is a known issue with GraalVM 20.0.0 - it should be resolved with newer version (20.0.1, 20.1.0) and also with JDK14+. See e.g. https://github.com/graalvm/graaljs/issues/271#issuecomment-614557588

We probably need to update our default dependency here for this example to the newest version (you can manually do that in your pom.xml).

Best, Christian

wirthi commented 4 years ago

I was probably to quick on this: even with GraalVM 20.1.0, the problem is not fixed because of a JVMCI problem on JDK 11.0.7.

If you use GraalVM 20.1.0, it will work on 11.0.6. (but not on 11.0.7.) and should also work on JDK14.

wirthi commented 4 years ago

This is further tracked in #32