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

Exception in code generation on Java 22 - NoSuchMethodError: void sun.misc.Unsafe.ensureClassInitialized #598

Open
edward3h opened this issue Jul 25, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@edward3h
Copy link

I created a minimal Gradle project to demonstrate the issue. https://github.com/edward3h/pkl-java22-unsafe

When using the pkl code generator in Gradle, on Java 22, I get an exception where this is the root cause:

Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoSuchMethodError: 'void sun.misc.Unsafe.ensureClassInitialized(java.lang.Class)' [in thread "Execution worker Thread 2"]
        at org.pkl.thirdparty.truffle.api.library.LibraryFactory.ensureLibraryInitialized(LibraryFactory.java:384)
        at org.pkl.thirdparty.truffle.api.library.LibraryFactory.getUncached(LibraryFactory.java:364)
        at org.pkl.thirdparty.truffle.api.library.LibraryFactory.<init>(LibraryFactory.java:210)
        at org.pkl.thirdparty.truffle.api.interop.InteropLibraryGen.<init>(InteropLibraryGen.java:178)
        at org.pkl.thirdparty.truffle.api.interop.InteropLibraryGen.<clinit>(InteropLibraryGen.java:169)
        at org.pkl.thirdparty.truffle.api.library.LibraryFactory.loadGeneratedClass(LibraryFactory.java:791)
        at org.pkl.thirdparty.truffle.api.library.LibraryFactory.resolveImpl(LibraryFactory.java:740)
        at org.pkl.thirdparty.truffle.api.library.LibraryFactory.resolve(LibraryFactory.java:733)
        at org.pkl.thirdparty.truffle.api.interop.InteropLibrary.<clinit>(InteropLibrary.java:2941)
        at org.pkl.thirdparty.truffle.polyglot.PolyglotValueDispatch.<clinit>(PolyglotValueDispatch.java:170)
        at org.pkl.thirdparty.truffle.polyglot.PolyglotImpl.initialize(PolyglotImpl.java:166)
        at org.pkl.thirdparty.graalvm.polyglot.impl.AbstractPolyglotImpl.setConstructors(AbstractPolyglotImpl.java:288)
        at org.pkl.thirdparty.graalvm.polyglot.Engine$1.loadAndValidateProviders(Engine.java:1107)
        at org.pkl.thirdparty.graalvm.polyglot.Engine$1.run(Engine.java:1067)
        at org.pkl.thirdparty.graalvm.polyglot.Engine$1.run(Engine.java:1061)
        at org.pkl.thirdparty.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1061)
        at org.pkl.thirdparty.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:143)
        at org.pkl.thirdparty.graalvm.polyglot.Engine.getImpl(Engine.java:367)
        at org.pkl.thirdparty.graalvm.polyglot.Engine$Builder.build(Engine.java:665)
        at org.pkl.core.runtime.VmUtils.<clinit>(VmUtils.java:74)

My projects work ok on Java 21.

@holzensp
Copy link
Contributor

This is a bug report for GraalVM/Truffle, I'm afraid. Pkl runs on GraalVM 23, which is compatible with JDK 17-21. I expect this to simply go away when we bump to a future GraalVM version that supports Java 22.

@bioball bioball added the bug Something isn't working label Aug 7, 2024
@sin-ack
Copy link

sin-ack commented Oct 1, 2024

FYI, based on this page it appears that Truffle 24+ supports Java 23 now: https://docs.oracle.com/en/graalvm/jdk/23/docs/release-notes/#platform-and-distributions

@translatenix
Copy link
Contributor

I think the problem is that Truffle 24+ doesn't support older Java versions.
I have some ideas on how to support a wider range of Java versions and avoid getting stuck on EOL'd Truffle/Graal versions.
I'll start a discussion after the 0.27 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants