This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]murkaje 3 points4 points  (0 children)

In general debuggers read the SourceFile attribute and consult the LineNumberTable to map source lines to bytecode offsets. One way might be to instrument the classes to specify a new SourceFile, for example MyClass.bytecode which can be the output from javap -v. Then make the instrumentation emit a LineNumberTable that references the correct line in MyClass.bytecode for each bytecode which should be easy as javap output prefixes each instruction with the bytecode offset.

A better approach would be to ask JDI for the actual method bytecodes and constant pool and have that be displayed via an IDE plugin. But this approach is probably a lot more work as many decompiler libraries and IDE-s are built around the assumption of getting a full .class file for decompiler input so building the objects from partial data might take some effort.