graalvm / graal-js-jdk11-maven-demo Goto Github PK
View Code? Open in Web Editor NEWAn example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
License: Universal Permissive License v1.0
An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
License: Universal Permissive License v1.0
I thought I'd got my build working with JDK17 following your example (using Zulu on Windows), but when I run in GitHub Actions (Zulu on Ubuntu) Surefire bombs out with the message: Cannot use JVMCI compiler: No JVMCI compiler found.
It is unclear what the implications of removing JVMCI are for polyglot programming on OpenJDK.
Dzmitrys-MacBook-Pro:graal-js-jdk11-maven-demo zmitrok$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
Dzmitrys-MacBook-Pro:graal-js-jdk11-maven-demo zmitrok$ mvn exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ my-app ---
=== Graal.js via org.graalvm.polyglot.Context ===
warming up ...
warmup finished, now measuring
iteration: 1322
iteration: 1347
iteration: 1340
iteration: 1352
iteration: 1335
iteration: 1358
iteration: 1349
iteration: 1370
iteration: 1341
iteration: 1330
=== Graal.js via javax.script.ScriptEngine ===
warming up ...
warmup finished, now measuring
iteration: 1322
iteration: 1308
iteration: 1333
iteration: 1321
iteration: 1321
iteration: 1244
iteration: 1309
iteration: 1323
iteration: 1323
iteration: 1307
=== 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: 238
iteration: 228
iteration: 231
iteration: 231
iteration: 226
iteration: 229
iteration: 230
iteration: 229
iteration: 225
iteration: 224
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:01 min
[INFO] Finished at: 2018-11-08T00:03:54-08:00
[INFO] ------------------------------------------------------------------------
Dzmitrys-MacBook-Pro:graal-js-jdk11-maven-demo zmitrok$
I created an Eclipse project, with an Execution Environment etc. to get your demo running. Everything seems ok, until the point I perform
Context graalContext = Context.create()
leaving me with a
java.lang.InternalError: Multiple org.graalvm.polyglot.impl.AbstractPolyglotImpl providers found
at org.graalvm.sdk/org.graalvm.polyglot.Engine$1.run(Engine.java:608)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$1.run(Engine.java:580)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.graalvm.sdk/org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:580)
at org.graalvm.sdk/org.graalvm.polyglot.Engine.access$000(Engine.java:99)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:108)
at org.graalvm.sdk/org.graalvm.polyglot.Engine.getImpl(Engine.java:261)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$Builder.build(Engine.java:484)
at org.graalvm.sdk/org.graalvm.polyglot.Context$Builder.build(Context.java:1083)
at org.graalvm.sdk/org.graalvm.polyglot.Context.create(Context.java:660)
at info.elexis.server.misthios.internal.MisthiosJavascriptBundle.execute(MisthiosJavascriptBundle.java:23)
at info.elexis.server.misthios.MisthiosTest.testJavascriptBundle(MisthiosTest.java:44)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:232)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:27)
at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:57)
at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:49)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:199)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:391)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:246)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
at org.eclipse.equinox.launcher.Main.main(Main.java:1474)
This is when I add the parameters (derived from your script)
--module-path=/Users/marco/test/graal-js-jdk11-maven-demo/target/compiler
-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
--upgrade-module-path=/Users/marco/test/graal-js-jdk11-maven-demo/target/compiler/compiler.jar
If I start JVM11 without graal it works.
eration: 174
=== Graal.js via org.graalvm.polyglot.Context ===
=== Graal.js via javax.script.ScriptEngine ===
org.graalvm.polyglot.PolyglotException: jdk.vm.ci.common.JVMCIError: VM config values not expected to be present in JDK 11 linux-amd64 (java.home=/usr/lib/jvm/java-11-openjdk-amd64, java.vm.name=OpenJDK 64-Bit Server VM, java.vm.version=11.0.8+10-post-Ubuntu-0ubuntu120.04):
CodeInstaller::FRAME_COMPLETE at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.<init>(GraalHotSpotVMConfig.java:886) [value: 6]
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.634 s <<< FAILURE! - in com.mycompany.app.AppTest
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.498 s <<< ERROR!
org.graalvm.polyglot.PolyglotException:
jdk.vm.ci.common.JVMCIError: VM config values not expected to be present in JDK 11 linux-amd64 (java.home=/usr/lib/jvm/java-11-openjdk-amd64, java.vm.name=OpenJDK 64-Bit Server VM, java.vm.version=11.0.8+10-post-Ubuntu-0ubuntu120.04):
CodeInstaller::FRAME_COMPLETE at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.<init>(GraalHotSpotVMConfig.java:886) [value: 6]
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] AppTest.testGraalPolyglotSpeed » Polyglot jdk.vm.ci.common.JVMCIError: VM conf...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.543 s
[INFO] Finished at: 2020-08-31T19:44:27+02: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 /home/frank/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
frank@frank-MS-7821:~/graal-js-jdk11-maven-demo$ mvn exec:exec
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ my-app ---
=== Graal.js via org.graalvm.polyglot.Context ===
Exception in thread "main" org.graalvm.polyglot.PolyglotException: jdk.vm.ci.common.JVMCIError: VM config values not expected to be present in JDK 11 linux-amd64 (java.home=/usr/lib/jvm/java-11-openjdk-amd64, java.vm.name=OpenJDK 64-Bit Server VM, java.vm.version=11.0.8+10-post-Ubuntu-0ubuntu120.04):
CodeInstaller::FRAME_COMPLETE at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.<init>(GraalHotSpotVMConfig.java:886) [value: 6]
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfigAccess.reportErrors(GraalHotSpotVMConfigAccess.java:224)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.<init>(GraalHotSpotVMConfig.java:67)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalRuntime.<init>(HotSpotGraalRuntime.java:161)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:156)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:134)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:52)
at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.getCompiler(HotSpotJVMCIRuntime.java:425)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.getCompiler(HotSpotTruffleCompilerImpl.java:138)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.create(HotSpotTruffleCompilerImpl.java:115)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.java.HotSpotTruffleRuntime.newTruffleCompiler(HotSpotTruffleRuntime.java:95)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.initializeTruffleCompiler(AbstractHotSpotTruffleRuntime.java:241)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.access$100(AbstractHotSpotTruffleRuntime.java:86)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime$1.execute(AbstractHotSpotTruffleRuntime.java:207)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.BackgroundCompileQueue$RequestImpl.call(BackgroundCompileQueue.java:188)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.BackgroundCompileQueue$TruffleCompilerThreadFactory$1.run(BackgroundCompileQueue.java:230)
Original Internal Error:
jdk.vm.ci.common.JVMCIError: VM config values not expected to be present in JDK 11 linux-amd64 (java.home=/usr/lib/jvm/java-11-openjdk-amd64, java.vm.name=OpenJDK 64-Bit Server VM, java.vm.version=11.0.8+10-post-Ubuntu-0ubuntu120.04):
CodeInstaller::FRAME_COMPLETE at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.<init>(GraalHotSpotVMConfig.java:886) [value: 6]
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfigAccess.reportErrors(GraalHotSpotVMConfigAccess.java:224)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.<init>(GraalHotSpotVMConfig.java:67)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalRuntime.<init>(HotSpotGraalRuntime.java:161)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:156)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:134)
at jdk.internal.vm.compiler/org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:52)
at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.getCompiler(HotSpotJVMCIRuntime.java:425)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.getCompiler(HotSpotTruffleCompilerImpl.java:138)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.create(HotSpotTruffleCompilerImpl.java:115)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.java.HotSpotTruffleRuntime.newTruffleCompiler(HotSpotTruffleRuntime.java:95)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.initializeTruffleCompiler(AbstractHotSpotTruffleRuntime.java:241)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.access$100(AbstractHotSpotTruffleRuntime.java:86)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime$1.execute(AbstractHotSpotTruffleRuntime.java:207)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.BackgroundCompileQueue$RequestImpl.call(BackgroundCompileQueue.java:188)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.BackgroundCompileQueue$TruffleCompilerThreadFactory$1.run(BackgroundCompileQueue.java:230)
Caused by: Attached Guest Language Frames (0)
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:804)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:751)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:313)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.112 s
[INFO] Finished at: 2020-08-31T19:53:05+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default-cli) on project my-app: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [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/MojoExecutionException
We got the same error with es4x that we have with mvn package and install
Exception in thread "main" org.graalvm.polyglot.PolyglotException: jdk.vm.ci.common.JVMCIError: VM config values not expected to be present in JDK 11 linux-amd64 (java.home=/usr/lib/jvm/java-11-openjdk-amd64, java.vm.name=OpenJDK 64-Bit Server VM, java.vm.version=11.0.8+10-post-Ubuntu-0ubuntu120.04):
I am trying to replace nashorn by GraalJS in a big Java application. Thus I can not start from this repository. Since I could not find information in the graal docs, I am asking this here:
The README.md file says under Pre-requirements that Linux or Mac OS is required.
I was able to run this demo just fine on my Windows machine with JDK 11.0.2. Does the README just need to be updated, or is there a reason Windows is not officially supported yet?
Are there any plans to release mvn deps for languages like Fast.R? Or if I build Fast.R locally, what jars do I need to add to the classpath?
Caused by: java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Paths.java:143)
at com.oracle.truffle.polyglot.LanguageCache.collectLanguages(LanguageCache.java:355)
at com.oracle.truffle.polyglot.LanguageCache.createLanguages(LanguageCache.java:247)
at com.oracle.truffle.polyglot.LanguageCache.languages(LanguageCache.java:237)
at com.oracle.truffle.polyglot.PolyglotEngineImpl.languages(PolyglotEngineImpl.java:578)
at com.oracle.truffle.polyglot.PolyglotEngineImpl.initializeLanguages(PolyglotEngineImpl.java:526)
at com.oracle.truffle.polyglot.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:198)
at com.oracle.truffle.polyglot.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:180)
at com.oracle.truffle.polyglot.PolyglotImpl.buildEngine(PolyglotImpl.java:180)
at org.graalvm.polyglot.Engine$Builder.build(Engine.java:505)
at org.graalvm.polyglot.Context$Builder.build(Context.java:1406)
at org.graalvm.polyglot.Context.create(Context.java:700)
at com.mycompany.app.App.benchGraalPolyglotContext(App.java:123)
at com.mycompany.app.App.main(App.java:115)
demo
git clone https://github.com/cameronbraid/graal-js-jdk11-maven-demo
mvn package exec:exec
Running on JDK 13 causes the following error when running mvn package
=== Graal.js via javax.script.ScriptEngine ===
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated
*** Graal.js not found ***
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.714 s <<< FAILURE! - in com.mycompany.app.AppTest
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.005 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.graalvm.polyglot.Engine$ImplHolder
at com.mycompany.app.AppTest.testGraalPolyglotSpeed(AppTest.java:59)
I'm running on OSX Mojave with the latest JDK from Oracle which outputs the following version info:
java -version
java version "13" 2019-09-17
Java(TM) SE Runtime Environment (build 13+33)
Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
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?
When running against OpenJ9 JVM (JDK11)
me@ubuntu:~/git/graal-js-jdk11-maven-demo$ export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-openj9-amd64
me@ubuntu:~/git/graal-js-jdk11-maven-demo$ mvn package
I get the following output:
=== 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: 515
iteration: 497
iteration: 515
iteration: 463
iteration: 503
iteration: 520
iteration: 467
iteration: 464
iteration: 479
iteration: 473
=== Graal.js via org.graalvm.polyglot.Context ===
warming up ...
warmup finished, now measuring
iteration: 2856
iteration: 2811
iteration: 2888
iteration: 2874
iteration: 2825
iteration: 2822
iteration: 2978
iteration: 2895
iteration: 3073
iteration: 2926
=== Graal.js via javax.script.ScriptEngine ===
warming up ...
warmup finished, now measuring
iteration: 3091
iteration: 3070
iteration: 2812
iteration: 2952
iteration: 2858
iteration: 2862
iteration: 2842
iteration: 2832
iteration: 2748
iteration: 2823
[ERROR] Failures:
[ERROR] AppTest.testGraalPolyglotSpeed:61 Graal.js (2926 ms) should be faster than Nashorn (473 ms).
[ERROR] AppTest.testGraalScriptEngineSpeed:70 Graal.js (2823 ms) should be faster than Nashorn (473 ms).
When running with hotspot, GraalJS beats Nashorn (and is overall faster than with OpenJ9 JVM).
It this an known/expected result?
Windows 11...
C:\Users\david\Documents\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 (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\david\Documents\graal-js-jdk11-maven-demo\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my-app ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\david\Documents\graal-js-jdk11-maven-demo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-dependency-plugin:2.10:copy (copy) @ my-app ---
[INFO] Configured Artifact: org.graalvm.compiler:compiler:22.2.0:jar
[INFO] Configured Artifact: org.graalvm.compiler:compiler-management:22.2.0:jar
[INFO] Configured Artifact: org.graalvm.truffle:truffle-api:22.2.0:jar
[INFO] Configured Artifact: org.graalvm.sdk:graal-sdk:22.2.0:jar
[INFO] Copying compiler-22.2.0.jar to C:\Users\david\Documents\graal-js-jdk11-maven-demo\target\compiler\compiler.jar
[INFO] Copying compiler-management-22.2.0.jar to C:\Users\david\Documents\graal-js-jdk11-maven-demo\target\compiler\compiler-management.jar
[INFO] Copying truffle-api-22.2.0.jar to C:\Users\david\Documents\graal-js-jdk11-maven-demo\target\compiler\truffle-api.jar
[INFO] Copying graal-sdk-22.2.0.jar to C:\Users\david\Documents\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 ===
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated
Warning: Nashorn engine is planned to be removed from a future JDK release
warming up ...
warmup finished, now measuring
iteration: 235
iteration: 204
iteration: 205
iteration: 192
iteration: 216
iteration: 219
iteration: 236
iteration: 219
iteration: 213
iteration: 200
=== Graal.js via org.graalvm.polyglot.Context ===
=== Graal.js via javax.script.ScriptEngine ===
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated
*** Graal.js not found ***
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.979 s <<< FAILURE! - in com.mycompany.app.AppTest
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.011 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.graalvm.polyglot.Engine$ImplHolder
at com.mycompany.app.AppTest.testGraalPolyglotSpeed(AppTest.java:59)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] AppTest.testGraalPolyglotSpeed:59 » NoClassDefFound Could not initialize class...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.912 s
[INFO] Finished at: 2022-11-30T19:23:32-08: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 C:\Users\david\Documents\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
C:\Users\david\Documents\graal-js-jdk11-maven-demo>
how increase perfomance compiling with the graal compiler using spring boot?
the example does not work with JDK12/13/14. It seem that the compiler.jar is not compatible with newer JDK's than 11.
JDK12:
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.185 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 initialize(Lorg/graalvm/compiler/hotspot/HotSpotGraalRuntime;Lorg/graalvm/compiler/hotspot/GraalHotSpotVMConfig;)V of interface org.graalvm.compiler.hotspot.HotSpotGraalManagementRegistration.
JDK13:
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.173 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.
JDK14:
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.166 s <<< ERROR!
org.graalvm.polyglot.PolyglotException: jdk.vm.ci.common.JVMCIError: expected type markOop but VM field oopDesc::_mark is of type markWord
I'm wondering if it's possible to information on how to include the dependencies required to run this sample with a standalone jar.
I have something similar to the following, where invokeFunction
returns an object myDataObject
here) internally of the type PolyglotMap
, but can only be typed statically as Object
. I'm wondering how the data can be extracted out.
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("graal.js");
URL url = Foobar.class.getClassLoader().getResource("foobar.js");
engine.eval(Files.newBufferedReader(Paths.get(url.toURI()), StandardCharsets.UTF_8));
Invocable inv = (Invocable) engine;
var myDataObject = (inv.invokeFunction("main", "testing data"));
I changed the graalvm.version from rc10 to rc11 and rc12 and it built successfully. When I change to rc13 it fails with:
[ERROR] testGraalPolyglotSpeed(com.mycompany.app.AppTest) Time elapsed: 0.005 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class com.oracle.truffle.api.TruffleOptions
at com.mycompany.app.AppTest.testGraalPolyglotSpeed(AppTest.java:59)
The Nashhorn test runs, then fails with the above error. This only occurs with rc13.
I'm currently working with GraalVM in Java and encountering an issue with the object type returned by a function. Here's the code snippet:
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
import org.graalvm.polyglot.HostAccess;
import org.graalvm.polyglot.Value;
myRunFunction(myOwnObject input) {
myOwnProxyObject finalInput = new myOwnProxyObject(input);
Object result;
try {
result = Engine.invokeFunction(myJSCode, finalInput, context, logger, data, anotherData);
} catch(Exception e){
//do something
}
//do other
}
The problem is that the result object is of type polygloMtap instead of the expected myOwnProxyObject.
Can anyone help me understand why this is happening and how I can ensure the function returns an object of type myOwnProxyObject? Any help would be greatly appreciated.
Here's what I've attempted so far:
Initially, I was working with the object type myOwnObject. However, after conducting some research, I realized that this approach might not be the most efficient. Despite this, I still received an object of type myOwnObject.
This led me to suspect that there might be an issue with the implementation of myOwnProxyObject. However, I'm currently unsure of what the specific problem could be. I'm looking for guidance on what could potentially be wrong with my myOwnProxyObject implementation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.