Add ABCL disassembler post.
[blog.git] / abcl-java-debugging.post
1 ;;;;;
2 title: Debugging Java with ABCL
3 date: 2016-09-10 00:05:24
4 format: md
5 tags: lisp
6 bindings: 3bmd-code-blocks:*code-blocks-default-colorize* :common-lisp
7 ;;;;;
8
9 So after adding a dispatch mechanism into the `DISASSEMBLE` function of ABCL I
10 also want to show a neat way of disassembling arbitrary Java classes using one
11 of the provided disassemblers.
12
13 First of, make sure that you have the ObjectWeb ASM library in your classpath
14 (everything up from version 3 should work at least, perhaps even lower
15 versions), note that in future releases you might be able to load it via Maven
16 and one of the optional contribs as well, likely via `(require '#:asm-all)`.
17
18 Next up, try `(disassemble #'list)` and confirm that some output is shown.
19
20 Now to show bytecode for arbitrary Java classes we've got to jump through some
21 additional hoops - though perhaps at some point this could become a stable API
22 as well:
23
24     (system::objectweb-disassemble (#"getResourceAsStream" (java:jclass "java.lang.Object") "/java/util/Random.class"))
25
26 I haven't tried this via the JAD disassembler, but it seems likely that a
27 similar approach should work for it too.