This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-11
Channels
- # announcements (1)
- # aws (4)
- # beginners (16)
- # cider (9)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (46)
- # clojure-brasil (1)
- # clojure-spec (3)
- # clojure-uk (4)
- # clojurescript (46)
- # cursive (26)
- # duct (1)
- # emacs (31)
- # figwheel (1)
- # fulcro (9)
- # graalvm (21)
- # kaocha (1)
- # nyc (1)
- # off-topic (4)
- # pathom (6)
- # planck (45)
- # re-frame (2)
- # reagent (11)
- # ring (5)
- # rum (9)
- # spacemacs (2)
- # sql (60)
- # tools-deps (3)
So, trying to run a simple "hello-world" type of clojure app - it compiles using native-image, but when I run it, I get this:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:287)
at java.lang.Class.ensureInitialized(DynamicHub.java:437)
at clojure.lang.Namespace.<init>(Namespace.java:34)
at clojure.lang.Namespace.findOrCreate(Namespace.java:176)
at clojure.lang.Var.internPrivate(Var.java:153)
at palindrome.core.<clinit>(Unknown Source)
at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:347)
at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:267)
at java.lang.Class.ensureInitialized(DynamicHub.java:437)
Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class or clojure/core.clj on classpath.
at clojure.lang.RT.load(RT.java:463)
at clojure.lang.RT.load(RT.java:426)
at clojure.lang.RT.doInit(RT.java:468)
at clojure.lang.RT.<clinit>(RT.java:336)
at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:347)
at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:267)
... 8 more
The solution to my problem was to add (flush) at the end of the program that worked
Okay, found the answer. With GraalVM 19.0.0, they have changed the way that classes are initialised at runtime
To fix the problem, and to have the native-image run perfectly, you just have to do this (showing an example project.clj)
(defproject palindrome "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url " "}
:dependencies [[org.clojure/clojure "1.9.0"]]
:plugins [[io.taylorwood/lein-native-image "0.3.0"]]
:native-image {:name "palindromes"
:opts ["--report-unsupported-elements-at-runtime"
"--initialize-at-build-time"]}
:main ^:skip-aot palindrome.core
:repl-options {:init-ns palindrome.core}
:profiles {:dev {:global-vars {*warn-on-reflection* true
*assert* true}}
:uberjar {:aot
:all
:native-image {:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}}})
The incantation is to add in the --initialize-at-build-time
flag for graalvm to do it's magic.