views:

2036

answers:

4

Hi,
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  A: 

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)

David Rabinowitz
Which decompiler would you recommend?
Thorbjørn Ravn Andersen
I haven't done decompilations lately (the open source advantage...) but I remember JAD and JODE to yield good results. See more at http://stackoverflow.com/questions/31353/ and http://stackoverflow.com/questions/1384619/
David Rabinowitz
Yes, I was considering this approach, but if there are many libraries this gets too annoying, so I am looking for a "automatic way" without any overhead.
tori3852
Take a command line decompiler, write an ant (or even shell) script that iterate through the files and generate the java files.
David Rabinowitz
+1  A: 

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

This didn't work with debug, for me.
tori3852
+2  A: 

I have good experience with Jadclipse - http://jadclipse.sourceforge.net/wiki/index.php/Main%5FPage - 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.

Thorbjørn Ravn Andersen
Well, this approach is most suitable - it seems to work (decompiles Java classes on the fly, shows source while debugging). Seems that I was on a good way, but missed to restart Eclipse few times. It would be perfect if all lines of decompiled file would match, because now I get manny MISALIGNED.
tori3852
Agree, but jad is not open source and the author seems to have abandoned it. Hopefully the new decompilers supported by jadclipse will eventually be even better than jad.
Thorbjørn Ravn Andersen
The MISALIGNED is due to the way that jad creates the decompiled source. I believe it writes serially, and cannot move back and forth to place things better.
Thorbjørn Ravn Andersen
+1  A: 

Hello. 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.

Emmanuel Dupuy
Cool :-) Please let us know
Nicolas Raoul