Some fun with GraalVM

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:

I am getting a weird error:

Error: Unsupported type 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.
        at parsing
Call path from entry point to
        at clojure.lang.RT.resourceAsStream(
        at clojure.lang.RT.compile(
        at clojure.lang.RT.load(
        at clojure.lang.RT.load(
        at clojure.core$load$fn__6546.invoke(core.clj:6046)

Not sure why it’s complaining about a 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 -?
 toycalc - A command-line toy calculator

 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 -?
 toycalc - A command-line toy calculator

 toycalc [global-options] command [command options] [arguments...]

real    0m0.005s
user    0m0.003s
sys     0m0.002s

Not half bad, is it? :smile:


BTW, I created a blog entry about it:

1 Like

Not half bad indeed. Thanks for sharing!

Typo spotted

, at the moment we have to tell Graal not to abort at compile time but to defer such exceptions to compile time

I think you want to defer them to runtime.

By the way, what really happened when this warning shows up? Does it mean it can agressively compile your code and falls back to dynamic class loading anyway in the final executable?

Thanks - will fix it. I’m an awful bad typist.

The idea is that it will crash and burn at runtime - so it’s bad, but at the moment I am aware of no better option. As it is in RT, I guess that there is nothing that can be done about it.

Ok so the compiler time warning is just about the possibility of a problem, not a signal that the app will crash no matter what. I get it, thanks.

Yes - but at that point you don’t know if it may crash and burn or not.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.