jgpc42 / insn

Functional JVM bytecode generation for Clojure.
Eclipse Public License 1.0
198 stars 5 forks source link

Clojure AOT compilation bug #1

Closed jgpc42 closed 7 years ago

jgpc42 commented 7 years ago

Currently, Clojure AOT compiling does not work with "dynamic" class imports like the ones used in this library.

The bug is shown here. I guess I'll report it if I get the time, but looking at the amount of open AOT-related bugs, I don't think it will be a high-priority fix.

I'm open to suggestions on how to handle this. The only thing that I can think of currently is to remove the ability to choose the ASM version you want to use.

jgpc42 commented 7 years ago

TLDR: AOT-compilation of insn now works: bbf6bb1

Deciphering Clojure stack traces sometimes is truly a daunting task, especially when seeing AOT-related ExceptionInInitializerError errors. :fearful:

Anyway, the larger issue turned out to be that when AOT-compiled, apparently *ns* is nil during the load. The imports are trying to update the ns-imports of the current namespace, which is set properly when interpreted, and not when compiled. This seems like it's related to the larger problem: CLJ-2185.

So I used custom a ns macro along with a poor mans eval-when-compile based on the above information.