Fork me on GitHub

Is there any way to debug compiled classes created by compile function from a CLJ source? I see some magic - a function calls another function with a not-nil argument, and the callee still receives nil. I see that the call stack includes 2 levels for each function call, so there must be something fishy going on in there.


Here's a piece of code of interest:

(defn write
  "Writes a value to a transit writer."
  [^Writer writer o]
  (.write ^com.cognitect.transit.Writer (.w writer) o))
When the current line is the very first one, writer is not null. But as soon as I step into , it becomes null for no apparent reason.


Ahh, the value there is not actually null - the NPE is in the .write function, a step further. But why does the debugger report null here? I'm in the debug mode, so locals should not be cleared. Let alone locals in the current frame.


I have -Dclojure.compiler.disable-locals-clearing=true in my :jvm-opts, and the corresponding button in the debug REPL is pushed in, so that shouldn't be it.


@U2FRKM4TW That definitely sounds like locals clearing. Note that locals clearing is a compile flag, it has to be set when you compile your code. If you’re loading from source then having it set in your runtime is sufficient since your code will be compiled when it’s loaded, but if you’re AOT compiling you’ll have to either set the flag before compiling or re-evaluate your code (i.e. re-send the file to the REPL) to have it be recompiled taking the flag into account.


Hmm, there's a change it was indeed AOT. Thanks!