Is there a disassembler + debugger for java (ala OllyDbg / SoftICE for assembler)?

后端 未结 2 530
Happy的楠姐
Happy的楠姐 2020-12-08 08:15

Is there a utility similar to OllyDbg / SoftICE for java? I.e. execute class (from jar / with class path) and, without source code, show the disassembly of the intermediate

相关标签:
2条回答
  • 2020-12-08 08:51

    I don't think this is really a full answer, but some pointers that may provide something workable:

    (1) In terms of viewing and directly working with bytecode the old BCEL Class Construction Kit can be useful (it's the only GUI editor for bytecode I'm aware of).

    (2) In terms of debugging and stepping through the bytecode, this Eclipse plugin, which integrates with Eclipse's debugger may meet your needs.

    I'm not aware of any utilities that would combine these features and allow you to manipulate bytecode while the code is being executed (at least in the same way you can in OllyDbg, etc.). However, the Java debugger API should be able to support manipulating the code at runtime (though, given the nature of HotSpot and JIT in general, I don't know if it would be possible to rewrite an instruction just before it is invoked --- the currently executing bytecode opcode is really an abstraction for how the interpreter chooses to implement the op, unlike native code where the disassembled opcode is, in fact, the instruction sent to the CPU). Alternatively, you could look into the Java Instrumentation API which provides a way to redefine byte code at runtime. And, of course, any of the various open source bytecode manipulation libraries may be able to help or provide inspiration.

    And, of course, there is always the option of of circumventing the whole JVM infrastructure and simply attaching a debugger to the JVM process. There's some discussion of this in this question and on this page linked from that question.

    The bottom line, however, is, that what you seem to be trying to accomplish, while common-place in the world of native code, is not all that common a practice in the Java world (part of the reason for using Java is abstraction from all the gory details). This, and the relatively trivial nature of byte code decompilation (compared with, say C++) has lead to a situation where this type of requirement is scarce and so is this type of tooling.

    0 讨论(0)
  • 2020-12-08 09:04

    Take a look at JAD Decomplier for decompiling Java code. You can then run an IDE's built-in debugger using produced sources. IDE can be IntelliJ, Eclipse or NetBeans. This approach is not completely automatic, but it should do the job.

    0 讨论(0)
提交回复
热议问题