I am getting GraalVM to run with CLI-matic to create small command line tools. It works - kind of. I am trying to run this: https://github.com/l3nz/cli-matic/blob/master/examples/toycalc.clj
I am getting a weird error:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported type java.net.JarURLConnection is reachable
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:239)
Call path from entry point to java.net.URLClassLoader.getResourceAsStream(String):
at java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:232)
at clojure.lang.RT.resourceAsStream(RT.java:2183)
at clojure.lang.RT.compile(RT.java:410)
at clojure.lang.RT.load(RT.java:458)
at clojure.lang.RT.load(RT.java:426)
at clojure.core$load$fn__6546.invoke(core.clj:6046)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:238)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eposix_002ethread_002ePosixJavaThreads_002epthreadStartRoutine_0028com_002eoracle_002esvm_002ecore_002eposix_002ethread_002ePosixJavaThreads_0024ThreadStartData_0029(generated:0)
Not sure why it’s complaining about a java.net.JarURLConnection
class…
But if work around the issue by adding a -H:+ReportUnsupportedElementsAtRuntime it just grinds on and on and at the end spits out a 25M executable that is compressed to ~7M.
-rwxr-xr-x 1 root root 25873378 Jul 19 22:12 testaot-0.2-standalone
-rwxr-xr-x 1 root root 7028008 Jul 19 22:12 testaot-0.2-standalone.gz
Now for the good news - this is a JVM execution:
# time ./graalvm-ce-1.0.0-rc4/bin/java -jar testaot-0.2-standalone.jar -?
NAME:
toycalc - A command-line toy calculator
USAGE:
toycalc [global-options] command [command options] [arguments...]
real 0m1.563s
user 0m2.755s
sys 0m0.156s
And this is compiled:
# time ./testaot-0.2-standalone -?
NAME:
toycalc - A command-line toy calculator
USAGE:
toycalc [global-options] command [command options] [arguments...]
real 0m0.005s
user 0m0.003s
sys 0m0.002s
Not half bad, is it?