开发者

How to debug compiled Java code in Eclipse [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_JAVA百科 Closed 9 years ago.

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.


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.


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.


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/


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


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

  1. extract the source files from the decompiled source zip file
  2. Run the script found at https://bushlife.com.au/groups/python/wiki/7539a/Adjust_line_numbers_in_file.html
  3. zip the generated source back up
  4. 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.


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)


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/


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜