Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 13 not working with GraalVM and -XX:+EnableJVMCI #1751

Closed
nhartner opened this issue Oct 14, 2019 · 7 comments
Closed

Java 13 not working with GraalVM and -XX:+EnableJVMCI #1751

nhartner opened this issue Oct 14, 2019 · 7 comments

Comments

@nhartner
Copy link

Running latest Java 13 SE from https://www.oracle.com/technetwork/java/javase/downloads/index.html, attempting to run with VM args -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI causes calls to org.graalvm.polyglot.Context.create("js") to fail with the following error:

Exception in thread "main" java.lang.InternalError: java.lang.IllegalAccessException: class com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader cannot access class jdk.vm.ci.services.Services (in module jdk.internal.vm.ci) because module jdk.internal.vm.ci does not export jdk.vm.ci.services to unnamed module @27f674d
	at com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader.load(DefaultTruffleRuntime.java:262)
	at com.oracle.truffle.api.impl.DefaultTruffleRuntime.getCapability(DefaultTruffleRuntime.java:235)
	at com.oracle.truffle.api.impl.TruffleLocator.loaders(TruffleLocator.java:74)
	at com.oracle.truffle.api.impl.Accessor.loaders(Accessor.java:109)
	at com.oracle.truffle.polyglot.EngineAccessor.allLoaders(EngineAccessor.java:97)
	at com.oracle.truffle.polyglot.LanguageCache.createLanguages(LanguageCache.java:246)
	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 test.App.main(App.java:49)
Caused by: java.lang.IllegalAccessException: class com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader cannot access class jdk.vm.ci.services.Services (in module jdk.internal.vm.ci) because module jdk.internal.vm.ci does not export jdk.vm.ci.services to unnamed module @27f674d
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:642)
	at java.base/java.lang.reflect.Method.invoke(Method.java:559)
	at com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader.load(DefaultTruffleRuntime.java:260)
	... 15 more

This works fine with Java 11 and 12.

@chumer
Copy link
Member

chumer commented Oct 17, 2019

Graal.js is not included by default in Java 13 SE.
Can you share the full command please, including the version of your Java 13 SE and the version of the jars you are using?
My first suspicion is that the JVMCI version shipped in Java 13 SE is not compatible with the Graal jars you are using.

@nhartner
Copy link
Author

@chumer I'm pulling GraalVM v19.2.0.1 jars via maven. Here's a simple example project to show what I am doing: https://github.com/nhartner/graalvm-java13-test

Running mvn compile exec:exec using JDK 11 works as expected:

REM-Z94G3L-M:graalvm-java13-test nhartner$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home/
REM-Z94G3L-M:graalvm-java13-test nhartner$ mvn compile exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< nhartner:graalvm-java13-test >--------------------
[INFO] Building graalvm-java13-test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ graalvm-java13-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/nhartner/workspace/graalvm-java13-test/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ graalvm-java13-test ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ graalvm-java13-test ---
success
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.151 s
[INFO] Finished at: 2019-10-17T12:29:05-06:00
[INFO] ------------------------------------------------------------------------

Switching to JDK 13, fails:

REM-Z94G3L-M:graalvm-java13-test nhartner$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/Home/
REM-Z94G3L-M:graalvm-java13-test nhartner$ mvn compile exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< nhartner:graalvm-java13-test >--------------------
[INFO] Building graalvm-java13-test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ graalvm-java13-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/nhartner/workspace/graalvm-java13-test/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ graalvm-java13-test ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ graalvm-java13-test ---
Exception in thread "main" java.lang.InternalError: java.lang.IllegalAccessException: class com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader cannot access class jdk.vm.ci.services.Services (in module jdk.internal.vm.ci) because module jdk.internal.vm.ci does not export jdk.vm.ci.services to unnamed module @77f03bb1
	at com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader.load(DefaultTruffleRuntime.java:262)
	at com.oracle.truffle.api.impl.DefaultTruffleRuntime.getCapability(DefaultTruffleRuntime.java:235)
	at com.oracle.truffle.api.impl.TruffleLocator.loaders(TruffleLocator.java:74)
	at com.oracle.truffle.api.impl.Accessor.loaders(Accessor.java:109)
	at com.oracle.truffle.polyglot.EngineAccessor.allLoaders(EngineAccessor.java:97)
	at com.oracle.truffle.polyglot.LanguageCache.createLanguages(LanguageCache.java:246)
	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 nhartner.App.main(App.java:13)
Caused by: java.lang.IllegalAccessException: class com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader cannot access class jdk.vm.ci.services.Services (in module jdk.internal.vm.ci) because module jdk.internal.vm.ci does not export jdk.vm.ci.services to unnamed module @77f03bb1
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:642)
	at java.base/java.lang.reflect.Method.invoke(Method.java:559)
	at com.oracle.truffle.api.impl.DefaultTruffleRuntime$Loader.load(DefaultTruffleRuntime.java:260)
	... 15 more
[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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    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:567)
    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.369 s
[INFO] Finished at: 2019-10-17T12:29:35-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default-cli) on project graalvm-java13-test: 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

@nhartner
Copy link
Author

Running on OSX Mojave, my java version info is

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)

@chumer
Copy link
Member

chumer commented Oct 23, 2019

@nhartner thanks for the detailed report!

Looks like we have a bug here. Note that we don't officially support JDK 13.

It seems like this bug is related to the default runtime when graal-truffle is not available.
As a workaround, can you try using the graal compiler.jar on the upgrade-module path as described here:
https://github.com/graalvm/graal-js-jdk11-maven-demo/blob/master/pom.xml#L56
?
That should go around that issue and at the same time enable compilation for Graal.js. Which you want for performance anyway.

@nhartner
Copy link
Author

@chumer same result. The demo project you mentioned does not work on Java 13. I filed a bug on that project as well graalvm/graal-js-jdk11-maven-demo#28
I believe the issue is a problem with the module-info.java files in one or more of the graal jars.

@nhartner
Copy link
Author

This appears to be fixed as of version 19.3.0

@ankitdeshmukh87
Copy link

Hi Team,

I am still running into : "ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated"

I am using jdk 11 , below is my code :

import javax.script.;
import java.util.
;
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("Graal.js"); // at this point it return null object for engine with the above error

I tried both ways :
1: By getting these jars and adding them manually to my project :
a: truffle-api-20.2.0.jar
b: js-scriptengine-20.2.0.jar
c: js-20.2.0.jar
d: graal-sdk-20.2.0.jar
e: compiler-20.2.0.jar
f: icu4j.jar icu4j-67.1jar

2: Also tried with the manually adding jars from the community edition : graalvm-ce-java11-darwin-amd64-20.2.0.tar.gz ( I am using on mac, unzipped it and added all required jars from it into my project in intellij )

For our application we want to use jars only with opensdk ( without using Maven or running from GraalVM that is not how we want to implement it ) and we want to ScriptEngine ( not polyglot api).

Kindly let me know if this issue is resolved ? and if so what is the workaround for the error I am getting .

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants