JDK 21 Breaks Clojure Libraries With Phantom Class References
New Compiler Behavior Causes Mysterious Errors
Users of the Jepsen testing library have been hitting strange ClassNotFoundException errors pointing to java.util.SequencedCollection, a Java interface that only exists in JDK 21 and later. The error is especially odd because Jepsen itself never directly references the class.
The root cause traces back to Clojure's built-in rrb_vector.clj and how the Clojure compiler behaves on JDK 21+. When compiling certain expressions, the compiler now inserts references to SequencedCollection—likely because the interface appears in the supertypes of other classes referenced during compilation.
Execution error (ClassNotFoundException) at
jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:641).
java.util.SequencedCollection
Existing Workarounds Fall Short
Jepsen already sets :javac-options ["-source" "11" "-target" "11"] in its project.clj, and developers also tried ["--release" "11"]. Neither worked because the references are injected by the Clojure compiler itself, not by javac.
As it stands, the only reliable workaround is to downgrade to Java 17 (or any version before 21) when building Jepsen as a library. That isn’t too difficult using update-alternatives, but it remains a hassle until the Clojure compiler gets a proper fix.



