The most sure-fire way to do this (and end up with something that's actually useful) is to download the source (you say that it is open-source), and set up another "Java Project" pointing at that source.
To do that, get the source downloaded and unzipped somewhere on your system. Click "File"->"New"->"Java Project". In the next dialog, give it a project name and select "Create Project from Existing Source". Browse to the root location of the open source library.
Supposing that all the additional libraries that are required by the project and such are included in the project you downloaded, Eclipse will figure everything out and set the build path up for you.
You'll need to remove the open source jar from your project's build path, and add this new project to the build path of your project.
Now, you can just treat this as your code, and debug at will.
This gets around at least a couple of problems with other approaches:
You could "attach source" to the jar file, but if the jar file was compiled without debug information, this still won't work. If the jar file was compiled with debug information (lines,source,vars
...see http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javac.html, and the -g
option).
You could add an "exception breakpoint" to see when the NullPointerException is raised, but that's a common exception, and may well get raised and dealt with many (hundreds of?) times prior to the one you're looking for. Plus, without the original source, you won't be able to really see much of anything about the code that is throwing the NullPointerException - the likelihood you'll be able to figure out what's wrong is pretty low.
-g
option? The doc states that-g : Generate all debugging information, including local variables.
, then onlysource
,lines
, &variable
are mentioned. I read on coderanch thatreal names of fields
are also used coderanch.com/t/262054/java-programmer-SCJP/certification/… . But nothing is mentioned about comments. – Eaves