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

'GraalJSEngineFactory could not be instantiated' on JDK22 #825

Open
dmercuriali opened this issue Jun 13, 2024 · 1 comment
Open

'GraalJSEngineFactory could not be instantiated' on JDK22 #825

dmercuriali opened this issue Jun 13, 2024 · 1 comment

Comments

@dmercuriali
Copy link

Hi,

we are using org.graalvm.js:js and org.graalvm.js:js-scriptengine 23.0.4 and I was doing some tests on jdk22.
The engine fails to initialize due to a removed method in java 22 sun.misc.Unsafe.ensureClassInitialized

java.util.ServiceConfigurationError: javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:809)
	at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:725)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1397)
	at java.scripting/javax.script.ScriptEngineManager.initEngines(ScriptEngineManager.java:105)
	at java.scripting/javax.script.ScriptEngineManager.<init>(ScriptEngineManager.java:76)
	at java.scripting/javax.script.ScriptEngineManager.<init>(ScriptEngineManager.java:63)
	...
Caused by: java.lang.NoSuchMethodError: 'void sun.misc.Unsafe.ensureClassInitialized(java.lang.Class)'
	at com.oracle.truffle.api.library.LibraryFactory.ensureLibraryInitialized(LibraryFactory.java:384)
	at com.oracle.truffle.api.library.LibraryFactory.getUncached(LibraryFactory.java:364)
	at com.oracle.truffle.api.library.LibraryFactory.<init>(LibraryFactory.java:210)
	at com.oracle.truffle.api.interop.InteropLibraryGen.<init>(InteropLibraryGen.java:178)
	at com.oracle.truffle.api.interop.InteropLibraryGen.<clinit>(InteropLibraryGen.java:169)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:529)
	at java.base/java.lang.Class.forName(Class.java:508)
	at com.oracle.truffle.api.library.LibraryFactory.loadGeneratedClass(LibraryFactory.java:791)
	at com.oracle.truffle.api.library.LibraryFactory.resolveImpl(LibraryFactory.java:740)
	at com.oracle.truffle.api.library.LibraryFactory.resolve(LibraryFactory.java:733)
	at com.oracle.truffle.api.interop.InteropLibrary.<clinit>(InteropLibrary.java:2941)
	at com.oracle.truffle.polyglot.PolyglotValueDispatch.<clinit>(PolyglotValueDispatch.java:170)
	at com.oracle.truffle.polyglot.PolyglotImpl.initialize(PolyglotImpl.java:169)
	at org.graalvm.polyglot.impl.AbstractPolyglotImpl.setConstructors(AbstractPolyglotImpl.java:288)
	at org.graalvm.polyglot.Engine$1.loadAndValidateProviders(Engine.java:1107)
	at org.graalvm.polyglot.Engine$1.run(Engine.java:1067)
	at org.graalvm.polyglot.Engine$1.run(Engine.java:1061)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
	at org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1061)
	at org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:143)
	at org.graalvm.polyglot.Engine.getImpl(Engine.java:367)
	at org.graalvm.polyglot.Engine$Builder.build(Engine.java:665)
	at com.oracle.truffle.js.scriptengine.GraalJSEngineFactory.<clinit>(GraalJSEngineFactory.java:70)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:340)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
	at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:173)
	at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:785)
	... 24 more
@iamstolis
Copy link
Member

If you want to use JDK 22+ then I suggest you to try newer versions (23.1.x or 24.0.x). Feel free to check this POM file to see what Maven artifacts are needed?

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

2 participants