12

What is the good Java debugger for .class files, if no source code available? jdb is seems pretty weak :( I don't need to decompile .class, but I want to debug bytecode.

3 Answers 3

14

Bytecode Visualizer
Inspect, understand and debug Java bytecode, no matter if you have the corresponding source.

JSwat Debugger
JSwat is a graphical Java debugger front-end, written to use the Java Platform Debugger Architecture and based on the NetBeans Platform. Its features include sophisticated breakpoints; colorized source code display with code navigator; movable display panels showing threads, call stack, visible variables, and loaded classes; command interface for more advanced features; and Java-like expression evaluation, including method invocation.

Java ByteCode Debugger (JBCD)
JBCD is an interactive debugger for Java bytecode. It allows a programmer to step through bytecode one statement at time. The tool is indended for people who are writing programs to generate or modify bytecode. JBCD can be used with any Java compiler

Bytecode Viewer
Bytecode Viewer is a Java Bytecode Viewer, GUI Procyon Java Decompiler, GUI CFR Java Decompiler, GUI FernFlower Java Decompiler, GUI Jar-Jar, Hex Viewer, Code Searcher, Debugger and more. It's written completely in Java, and it's open sourced.

JavaSnoop
A tool that lets you intercept methods, alter data and otherwise hack Java applications running on your computer.

Bytecode Outline
Bytecode Outline plugin shows disassembled bytecode of current java editor or class file, allows bytecode/ASMifier code compare for java/class files and shows ASMifier code for current bytecode. It also allows to disassemble and debug classes without attached source code on any operating system where Eclipse is running.

Addendum: This blog from Crowdstrike Inc. will also be helpful

4
  • 1
    Thanks for the blog link! I'll talk to our webmaster to see if he can fix the broken images. Commented Jan 10, 2015 at 19:02
  • Just a note to say that your first offering, Bytecode Visualizer, does not show you the stack or variable table, which is kind of a major limitation. I take it from your description that JSwat does, but that seems to be discontinued. Commented Jul 1, 2015 at 1:34
  • Most of these are far too old to be useful. The Dr. Garbage stuff doesn't work in recent Eclipses etc. JBCD is from 2003 and was probably useless even you wrote this answer, except for Java 2 or something that ancient. Commented Jun 26 at 6:45
  • And Bytecode Viewer, which is still maintained, might claim it's a "Debugger", but it isn't. Commented Jun 26 at 7:00
1

Possibly the best disassembler & assembler is Krakatau. It's written in python. Bytecode viewer has built-in Krakatau, but it sometimes can't perform as expected.

Another one is dirtyjoe which is also a great tool.

0

The real answer as of mid-2024 is this:

Also I asked Col-E(Recaf’s Developer) about any good bytecode debuggers and unfortunately, it turns out there aren’t any as of now!

The Bytecode Visualizer doesn't run in any Eclipse from the past 9 years or so. The other tools (except JSwat) from the top-voted answer aren't actually debuggers (even though some claim that in their description.) JSwat probably never had byte-code level stepping based on its more detail description (on github) and has also been dead for 10+ years.

Your best bet: use jdb (with step) and watch the bci (byte code instruction) counter, while having the disassembled file on the side.

If you wonder what Recaf is: a perhaps better version of Bytecode Viewer, but still not a debugger. These two are static analyzers that let you search for strings, method/field site calls etc. Recaf lets you also modify bytecode and reassemble. (Sometimes the result is broken though, esp. with newer features like INVOKEDYNAMIC.)

And if you want to try your hand at dynamic instrumentation, btrace is a modern/supported tool and can run in unsafe mode, in which it can modify stuff. Ibid Byte Buddy. Neither is a debugger as such though. They substitute for the defunct JavaSnoop though (but are not 'zero-conf' unlike that thingy). Both of these [as did JavaSnoop] use the Java agent interface, not the debugging API.

Now to be slightly more pedantic on the last point, Oracle/Sun did unify the APIs under one umbrella of JVMTI, so the step function and the bytecode retransform are in the same thingy, but generally tools that use one don't use the other and vice-versa.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.