How To Debug Without Source Code
Posted By : Anil Kumar Maurya | 28-May-2018
Debugging gives much relief to developers. But sometimes we required debugging our own code as well as someone's else code which might not have the source code. The main goal of this blog is to be able to debug through class files without having the source code and being able to step through the code having the debugger always pointing the correct line of the code.
In order to debug class files without having the source code, we need to install JD-eclipse and its extension JD-eclipse realignment fragment. JD-Eclipse is a plugin for the Eclipse/STS(Spring Tool Suite) ide. It allows you to show all the Java sources while debugging, even if you do not have the source code. Bytecode Visualizer is another plugin that is also used as a java decompiler. The main advantage of using JD-eclipse realignment jar is that your debug pointer will always point to the correct line of code.
Installation:
JD-Eclipse:
Go to the site http://jd.benow.ca/
Click the download tab of JD-Eclipse and download the
For installation follow instructions as provided on the site
Install and restart Eclipse.
realignment.jd.ide.eclipse_1.0.2.jar:
Go to the site https://sourceforge.net/projects/realignmentjd/files/ and download the jar
Copy the jar to the Eclipse's plugins folder and restart Eclipse.
Configurations:
Start the eclipse and Go to Windows -> Preferences -> General -> Editors -> File Associations
Select *.class in the File types section
Click add button in the Associated editors' section and select JD Class File viewer
Click the apply and close button
Repeat the same process for *.class without source file system.
Debugging the class file:
Go to your project in the project explorer, select the jar and open the class file with JD-Eclipse editor
Set the breakpoints in methods which you want to debug
Start the application in debug mode and start debugging.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Anil Kumar Maurya
Anil is an experienced Lead with core knowledge of Java, Spring, and SQL. He has good working experience in banking, finance and trading domain.