可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I wonder if there are any solutions for Eclipse IDE to debug Java code for which I have no source, i.e. to debug dynamically decompiled code, step through it, etc.? I tried to use JD-Eclipse, JadClipse, and these plug-ins work great if I want to look at some class files, but as I debug, I get "Source not found." - how can I "attach" these plug-ins to "provide" source?
My environment:
- Eclipse 3.5
- Windows XP (but I look for a cross platform solution, if possible)
Thank you.
回答1:
I have good experience with Jadclipse - http://jadclipse.sourceforge.net/wiki/index.php/Main_Page - there is an update site at http://jadclipse.sf.net/update
For best results, use jad and configure it to list line numbers as comments which will enable the output where the code is on the correct line. This is best for debugging sessions.
Then set it to be the default view for classes. See the documentation for details. This works well for me.
回答2:
I have the same problem. Today, no decompilers are efficent to debug compiled Java code. I'm working on JD-Eclipse. In the next 3 to 6 months, the layout of JD-Eclipse should be really improved. We will start to debug classes without sources and solve some intractable problems.
回答3:
Realignment fragment for JD-Eclipse host plug-in. This plug-in for Eclipse makes the decompiled code line numbers actually appropriate to the line numbers from the java-class file. As a result, it becomes possible debugging without source code. https://sourceforge.net/projects/realignmentjd/
回答4:
This plugin should hopefully be of help. JD-Eclipse
In eclipse open Window -> Preferences -> General ->Editors -> File Associations
Select *.class file type
Associate it with JD-Eclipse
Set it to default
Good Luck
回答5:
You can use JD-GUI to decompile jar files and save the whole lot into a source zip file which can then be added to the source search list (via Configure Build Path).
The problem with JD-GUI is that the line numbers are out which makes debugging very difficult, so you need to
- extract the source files from the decompiled source zip file
- Run the script found at https://bushlife.com.au/groups/python/wiki/7539a/Adjust_line_numbers_in_file.html
- zip the generated source back up
- add it as the source path associated with your java file - using Configure Build Path after right clicking on the jar file in your java project.
回答6:
Decompile all the classes, put all the Java files ordered in the proper hierarchy (directory for package, etc.) and then add them as the source of the original jar by right clicking the jar file -> Java Source Attachment -> External folder.
You can also have them inside a folder in the project (click on Workspace in this case)
回答7:
The solution that worked for me is using the JD-Eclipse after applying the patch: http://java.decompiler.free.fr/?q=node/464
This is an extension of jd-eclipse which realigns the code after decompiling.
When debugging with eclipse you just need to have the jar files in the classpath and that's it!
There's no need to decompile the whole jar, realign or whatsoever... Just debug and be happy :-)
Here's how to do it:
http://gauchoacomecable.wordpress.com/2011/10/14/eclipse-debug-java-without-source-code-jd-eclipse-and-realignment/
回答8:
I have enhanced the "Realignment for JD Eclipse" plugin to properly line up enums and fields and published it along with JD Eclipse on my own update site: http://mchr3k-eclipse.appspot.com/
Details about my changes: http://mchr3k-coding.blogspot.co.uk/2012/07/realignment-for-jd-eclipse.html