taoensso / nippy

The fastest serialization library for Clojure
https://www.taoensso.com/nippy
Eclipse Public License 1.0
1.04k stars 60 forks source link

GraalVM support #119

Closed borkdude closed 4 years ago

borkdude commented 5 years ago

I'm trying to use nippy with GraalVM in a native binary. When calling thaw-from-file, I get this exception (see below). If you're interested I can make a repro for you. I hope this can be solved, since it would be cool to use nippy for fast command line apps.

Exception in thread "main" java.lang.AssertionError: java.lang.ClassNotFoundException: net.jpountz.lz4.LZ4JavaSafeCompressor
    at net.jpountz.lz4.LZ4Factory.instance(LZ4Factory.java:53)
    at net.jpountz.lz4.LZ4Factory.safeInstance(LZ4Factory.java:98)
    at net.jpountz.lz4.LZ4Factory.fastestJavaInstance(LZ4Factory.java:134)
    at net.jpountz.lz4.LZ4Factory.fastestInstance(LZ4Factory.java:162)
    at taoensso.nippy.compression$fn__4902.invokeStatic(compression.clj:102)
    at taoensso.nippy.compression$fn__4902.invoke(compression.clj:102)
    at clojure.lang.Delay.deref(Delay.java:42)
    at clojure.core$deref.invokeStatic(core.clj:2320)
    at clojure.core$deref.invoke(core.clj:2306)
    at taoensso.nippy.compression$fn__4906.invokeStatic(compression.clj:115)
    at taoensso.nippy.compression$fn__4906.invoke(compression.clj:115)
    at clojure.lang.Delay.deref(Delay.java:42)
    at clojure.core$deref.invokeStatic(core.clj:2320)
    at clojure.core$deref.invoke(core.clj:2306)
    at taoensso.nippy.compression.LZ4Compressor.decompress(compression.clj:90)
    at taoensso.nippy$thaw$thaw_data__5765.invoke(nippy.clj:1420)
    at taoensso.nippy$thaw.invokeStatic(nippy.clj:1449)
    at taoensso.nippy$thaw.invoke(nippy.clj:1372)
    at taoensso.nippy$thaw_from_file.invokeStatic(nippy.clj:1692)
    at taoensso.nippy$thaw_from_file.invoke(nippy.clj:1676)
    at taoensso.nippy$thaw_from_file.invokeStatic(nippy.clj:1685)
    at taoensso.nippy$thaw_from_file.invoke(nippy.clj:1676)
    at clj_kondo.main$_main.invokeStatic(main.clj:208)
    at clj_kondo.main$_main.doInvoke(main.clj:160)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clj_kondo.main.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: net.jpountz.lz4.LZ4JavaSafeCompressor
    at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:51)
    at java.lang.ClassLoader.loadClass(Target_java_lang_ClassLoader.java:130)
    at net.jpountz.lz4.LZ4Factory.classInstance(LZ4Factory.java:170)
    at net.jpountz.lz4.LZ4Factory.<init>(LZ4Factory.java:184)
    at net.jpountz.lz4.LZ4Factory.instance(LZ4Factory.java:51)
    ... 25 more
borkdude commented 4 years ago

I believe @justone and I have figured out the issue. It can be resolved using a reflection configuration (https://github.com/oracle/graal/blob/master/substratevm/REFLECTION.md). Expect to hear more about this in the near future.

borkdude commented 4 years ago

https://github.com/justone/brisk