1. 程式人生 > >反編譯java class並優雅的除錯--http://www.blogjava.net/miaoyachun/archive/2013/02/22/395575.html

反編譯java class並優雅的除錯--http://www.blogjava.net/miaoyachun/archive/2013/02/22/395575.html

https://sourceforge.net/projects/realignmentjd/files/ 官方文件



用jd-eclipse 外掛來反編譯java class檔案的輸出還是挺nice的,雖然閱讀方便了 但是對debug確造成一定的困擾,主要問題是line number的不match.
Google了下遇到類似問題的真不少。最終找到了解決方案:
http://sourceforge.net/projects/realignmentjd/files/
-----------------

1. Download JD-Eclipse and JD-GUI - http://java.decompiler.free.fr/ and install.
2. Put a file realignment.jd.ide.eclipse_1.0.2.jar in eclipse/plugins directory.
    To use Realignment feature it is necessary to open the menu Preferences/General/Editors/File Associations and to select "*.class" file type and to choose "Realignment for JD Class File Editor" for Associated editors.
    Another possibility is the batch realignment after processing JD-GUI. To work properly you must to switch on the property "Display line numbers" in Help/Preferences of JD-GUI.
    To use this feature it is necessary to open the menu Preferences/Java/Decompiler/Batch Realignment and click button "Open dialog". Existing limitation: the realignment is performed only for the methods.
    To work properly it is necessary that the property "Display line numbers" in menu "Preferences/Java/Decompiler" was active.

JD-Eclipse外掛 +
realignment 補丁讓優雅的debug class 檔案成為可能。

如果只是為了閱讀class程式碼,建議不要用 realignment 補丁,這樣會降低程式碼的可讀性(會多出大量的空行)