Clerk doesn't load in java 22
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 .
@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).
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.
@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).
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.
io.github.nextjournal/markdown {:git/sha "6683c48dfdb23404a23057817b6ac3acf0310bca"}
Confirmed that this works. I'm able to load Clerk with Java 22.
Is there a general fix coming? We are using lein so the git sha trick doesn't work.
Please put this issue and the workaround to use the latest commit somewhere visible in the readme and/or the book.
I'm a first time user, and only by luck (well, by searching closed issues too, not just the open ones) I found this and I managed to successfully start Clerk.
There's a new release in clojars that should take care of this. Please give it a test! :)
I just updated to Clerk 0.17.1102 and it all seems to work now without the manual git pin on io.github.nextjournal/markdown. Thanks!
I can also confirm that the new version works! Thanks for the fix!
Btw, even though https://github.com/nextjournal/book-of-clerk/blob/main/book.clj#L64 has been changed to state the newest version, the https://book.clerk.vision is still "Generated with Clerk from book.clj@b4c03cf" and it shows v0.14: https://github.com/nextjournal/book-of-clerk/blob/b4c03cfb272f516a287c51133dd2dc0a71f274f0/book.clj#L63
@narimiran the book is now updated as well.