nextjournal / clerk

⚡️ Moldable Live Programming for Clojure
https://clerk.vision
ISC License
1.74k stars 75 forks source link

Clerk doesn't load in java 22 #642

Open qrthey opened 3 months ago

qrthey commented 3 months ago

Java 22 seems to have removed sun.misc.Unsafe.ensureClassInitialized(java.lang.Class) but it is required when loading the nextjournal.clerk namespace (or one of its dependencies). The error specifies that the error occurs during compilation of markdown.clj.

Local setup: Java 22, clojure 1.11.2, clerk 0.15.957 (arch linux, emacs cider 1.14, nREPL 1.1.1)

Can be reproduced by just having the Clerk dependency in deps.edn and evaluating following ns expression:

(ns test-clerk
  (:require [nextjournal.clerk :as clerk]))

The documentation currently states that clerk should work on Java 11 and higher.

edit: Seems to originate from org.graalvm.polyglot used in https://github.com/nextjournal/markdown/blob/main/src/nextjournal/markdown.clj#L7 .

zampino commented 3 months ago

@qrthey thank you for reporting this! Graal has addressed the removal of sun.misc.Unsafe in java 22. I need to find a version of org.graalvm.js/js which uses the latest truffle api (https://github.com/nextjournal/markdown/issues/23).

zampino commented 3 months ago

I opened https://github.com/nextjournal/markdown/pull/24 bumping Graal polyglot libraries to support Java 22, but we'll lose support for Java 16 and earlier, the oldest supported would be 17.

zampino commented 3 months ago

@qrthey as a temporary workaround, to use Java 22 you might use nextjournal/markdown from github source as per

io.github.nextjournal/markdown {:git/sha "6683c48dfdb23404a23057817b6ac3acf0310bca"}

in your project deps.edn (you might need to exclude the jar dependency from clerk if clojure makes troubles resolving deps of different manifest types).

qrthey commented 3 months ago

Thanks @zampino . In my daily use of clerk, we are still on java 17. I just stumbled over this when trying some new java 22 stuff.

In general I can see that it might be difficult to force users to upgrade to newer Java versions OR to have them not use the latest version.

fosskers commented 3 months ago
io.github.nextjournal/markdown {:git/sha "6683c48dfdb23404a23057817b6ac3acf0310bca"}

Confirmed that this works. I'm able to load Clerk with Java 22.