Restore Debug Info functionality is accessible from the Tools menu and from the command line (command line support is described at the end).

The main idea behind this feature is to enable bytecode-level debugging of any .class file in any source-level Java debugger (e.g. JSwat, jdb). Restoring debug information consist of two stages:
  • Restoring Line Numbers
  • Restoring Local Variables
Restoring line numbers is fairly easy, it justs generates LineNumberTable attribute for each function. Line numbers inside this attribute are paired with line numbers taken from disassembled file (with .joe extension). Example of generated .joe file can be found below:
;-------------------------------------------------------------------------------
; File generated by dirtyJOE v1.6 (c466) (x86)
; Copyright  2008-2013 ReWolf
; http://dirty-joe.com
; joe@dirty-joe.com
;-------------------------------------------------------------------------------

java.lang.Object getObjectLock()
00000000: 	aload_0
00000001: 	getfield            java.lang.Object java.awt.Component.objectLock
00000004: 	areturn
;-------------------------------------------------------------------------------

int getBoundsOp()
00000000: 	getstatic           boolean java.awt.Component.$assertionsDisabled
00000003: 	ifne                pos.00000018
00000006: 	aload_0
    
Restoring local variables is experimental feature and it might not work as supposed. Currently it tries to assign proper type (int, long, float, double, object reference) and scope to every local variable referenced in the bytecode. For object references it will always assign java.lang.Object type, as it doesn't perform any deep analysis of the function. Scope of the variable is based on the simple analysis of control flow instructions and exception handlers.

Command line support

Restore Debug Info feature is also available directly from the command line:

dirtyJOE should be started through "start /WAIT" command, as it is not console application thus it will run asynchronously without this command:
    start /WAIT dirtyJOE.exe /rdi class_file.class
    
Command line support was introduced to help with restoring debug info in multiple files. Below command will restore debug information for all files in the current directory and all subdirectories (.joe files will be placed in the same subdirectories as input .class files):
    for /R %c in (*.class) do start /WAIT dirtyJOE.exe /rdi "%c"
    
Command line version of Restore Debug Info doesn't create copy of the input class file thus you should always work on backup copy of the class file. It will also overwrite all existing .joe disassembled files.



(C) 2008-2014, ReWolf