From: Olof-Joachim Frahm Date: Fri, 9 Sep 2016 22:12:33 +0000 (+0200) Subject: Add ABCL disassembler post. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=22c80ff1053c9711d0f18987ee8d15fc0f4e5580;p=blog.git Add ABCL disassembler post. --- diff --git a/abcl-java-debugging.post b/abcl-java-debugging.post new file mode 100644 index 0000000..a93a449 --- /dev/null +++ b/abcl-java-debugging.post @@ -0,0 +1,27 @@ +;;;;; +title: Debugging Java with ABCL +date: 2016-09-10 00:05:24 +format: md +tags: lisp +bindings: 3bmd-code-blocks:*code-blocks-default-colorize* :common-lisp +;;;;; + +So after adding a dispatch mechanism into the `DISASSEMBLE` function of ABCL I +also want to show a neat way of disassembling arbitrary Java classes using one +of the provided disassemblers. + +First of, make sure that you have the ObjectWeb ASM library in your classpath +(everything up from version 3 should work at least, perhaps even lower +versions), note that in future releases you might be able to load it via Maven +and one of the optional contribs as well, likely via `(require '#:asm-all)`. + +Next up, try `(disassemble #'list)` and confirm that some output is shown. + +Now to show bytecode for arbitrary Java classes we've got to jump through some +additional hoops - though perhaps at some point this could become a stable API +as well: + + (system::objectweb-disassemble (#"getResourceAsStream" (java:jclass "java.lang.Object") "/java/util/Random.class")) + +I haven't tried this via the JAD disassembler, but it seems likely that a +similar approach should work for it too.