athos / JiSE

JiSE: Java in S-Expression
Eclipse Public License 2.0
104 stars 2 forks source link

Emit local variable info for better debuggability #10

Closed athos closed 4 years ago

athos commented 4 years ago

This PR enables JiSE emitter to emit local variable info to the resulting bytecode to make it easier to debug it using a stock Java decompiler. Resolves #9.

This behavior is disabled by default (as with javac, which generates local variable info if the -g option is specified). A user can turn it on by setting a new system property jise.debug to true. So if you're using Clojure CLI, for example, you can launch a REPL with this debug option enabled with clj -J-Djise.debug=true.

Note that the property name (jise.debug) itself is subject to change before the final release.

athos commented 4 years ago

@xificurC Any thoughts?

xificurC commented 4 years ago

Thanks, I'll test this once merged. I was thinking if it might make sense to allow per-class or per-method emission via e.g. metadata (^:debug), but the global switch is probably enough

athos commented 4 years ago

Okay, then I'll merge it first 👍

I was thinking if it might make sense to allow per-class or per-method emission via e.g. metadata (^:debug)

Yeah, I thought there might be such a demand, but I wanted to keep things simple as a first step.

xificurC commented 4 years ago

I'm not sure why I wanted you to merge first. No harm done I guess.

I just tested it and the decompiled output shows the variable names and it helped the decompiler decide which local vars were supposed to be final. Thanks!

athos commented 4 years ago

No worries! I'm happy to hear that result 🤗