Created
August 22, 2017 22:53
-
-
Save jgpc42/9091bf5d0f4fcd017977d10a82e6f2a9 to your computer and use it in GitHub Desktop.
Clojure AOT compilation and imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import [java.io InputStream]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns baz | |
(:require foo) | |
(:gen-class)) | |
(defn -main [] | |
(foo/print-it)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo | |
"Comment out the :load line and uncomment the :import line and no NPE is thrown." | |
(:load "bar") | |
#_(:import [java.io InputStream])) | |
(defn print-it [] | |
(println InputStream)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLOJURE=~/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar | |
java -cp "$CLOJURE":. clojure.main -m baz | |
# => java.io.InputStream | |
rm -rf classes/ && mkdir classes | |
java -cp "$CLOJURE":classes:. clojure.main -e "(compile 'baz)" | |
# => baz | |
java -cp "$CLOJURE":classes baz | |
# Exception in thread "main" java.lang.ExceptionInInitializerError | |
# at java.lang.Class.forName0(Native Method) | |
# at java.lang.Class.forName(Class.java:348) | |
# at clojure.lang.RT.classForName(RT.java:2168) | |
# at clojure.lang.RT.classForName(RT.java:2177) | |
# at clojure.lang.RT.loadClassForName(RT.java:2196) | |
# at clojure.lang.RT.load(RT.java:443) | |
# at clojure.lang.RT.load(RT.java:419) | |
# at clojure.core$load$fn__5677.invoke(core.clj:5893) | |
# at clojure.core$load.invokeStatic(core.clj:5892) | |
# at clojure.core$load.doInvoke(core.clj:5876) | |
# at clojure.lang.RestFn.invoke(RestFn.java:408) | |
# at foo$loading__5569__auto____5.invoke(foo.clj:1) | |
# at foo__init.load(Unknown Source) | |
# at foo__init.<clinit>(Unknown Source) | |
# at java.lang.Class.forName0(Native Method) | |
# at java.lang.Class.forName(Class.java:348) | |
# at clojure.lang.RT.classForName(RT.java:2168) | |
# at clojure.lang.RT.classForName(RT.java:2177) | |
# at clojure.lang.RT.loadClassForName(RT.java:2196) | |
# at clojure.lang.RT.load(RT.java:443) | |
# at clojure.lang.RT.load(RT.java:419) | |
# at clojure.core$load$fn__5677.invoke(core.clj:5893) | |
# at clojure.core$load.invokeStatic(core.clj:5892) | |
# at clojure.core$load.doInvoke(core.clj:5876) | |
# at clojure.lang.RestFn.invoke(RestFn.java:408) | |
# at clojure.core$load_one.invokeStatic(core.clj:5697) | |
# at clojure.core$load_one.invoke(core.clj:5692) | |
# at clojure.core$load_lib$fn__5626.invoke(core.clj:5737) | |
# at clojure.core$load_lib.invokeStatic(core.clj:5736) | |
# at clojure.core$load_lib.doInvoke(core.clj:5717) | |
# at clojure.lang.RestFn.applyTo(RestFn.java:142) | |
# at clojure.core$apply.invokeStatic(core.clj:648) | |
# at clojure.core$load_libs.invokeStatic(core.clj:5774) | |
# at clojure.core$load_libs.doInvoke(core.clj:5758) | |
# at clojure.lang.RestFn.applyTo(RestFn.java:137) | |
# at clojure.core$apply.invokeStatic(core.clj:648) | |
# at clojure.core$require.invokeStatic(core.clj:5796) | |
# at clojure.core$require.doInvoke(core.clj:5796) | |
# at clojure.lang.RestFn.invoke(RestFn.java:408) | |
# at baz$loading__5569__auto____3.invoke(baz.clj:1) | |
# at baz__init.load(Unknown Source) | |
# at baz__init.<clinit>(Unknown Source) | |
# at java.lang.Class.forName0(Native Method) | |
# at java.lang.Class.forName(Class.java:348) | |
# at clojure.lang.RT.classForName(RT.java:2168) | |
# at clojure.lang.RT.classForName(RT.java:2177) | |
# at clojure.lang.RT.loadClassForName(RT.java:2196) | |
# at clojure.lang.RT.load(RT.java:443) | |
# at clojure.lang.RT.load(RT.java:419) | |
# at clojure.core$load$fn__5677.invoke(core.clj:5893) | |
# at clojure.core$load.invokeStatic(core.clj:5892) | |
# at clojure.core$load.doInvoke(core.clj:5876) | |
# at clojure.lang.RestFn.invoke(RestFn.java:408) | |
# at clojure.lang.Var.invoke(Var.java:379) | |
# at clojure.lang.Util.loadWithClass(Util.java:250) | |
# at baz.<clinit>(Unknown Source) | |
# Caused by: java.lang.NullPointerException | |
# at bar__init.load(Unknown Source) | |
# at bar__init.<clinit>(Unknown Source) | |
# ... 56 more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment