How do you set a breakpoint in a class file (possibly contained in a JAR) for which you do not have the source code?
I'm writing some code that calls the Oracle JDBC driver. My code looks fine (of course) and I suspect the drive is doing something funny. I'd like to put in a breakpoint in the Oracle JDBC driver's preparedStatement object and see what it thinks I've passed in as parameters.
So, how do I set a breakpoint for source code that I do not have, only the compiled class file?
Hy Partik! On Sourcforge exists a project called JadClipse. This is a Eclipse-Plugin, which uses JAD to decompile your Class-File and show the source in your Eclipse-Editor. Then you can set Breakpoints...
My expirience with JadEclipse is, that it can be sometimes very tricky, to get it working.
Pratik R Patel
posted 15 years ago
thanks for the tips. I knew about the "step into", but with a huge method stack, it can take forever to click deep into the JDBC driver.
I'll have a look at JadClipse.
I did find after searching for a few hours more (the eclipse site's mail/news interface makes it so hard to find something) that you can simply do this: - Open the JAR file in the Package explorer (click the +) - Browse to the class file you want to breakpoint - In the outline view, click on the method you wish to breakpoint - Select 'Toggle Breakpoint'
of course, this only lets you set a breakpoint around the method and not somewhere inside. But this was enough for me to see that there's probably a bug in the Oracle JDBC driver
Is there any way to set a breakpoint on an interface's method, or do I have to show the type hierarchy and set a breakpoint on each implementation class? I want a breakpoint any time a method gets called.
Breakpoints are only set on the actual code that is running. If you set a breakpoint in a superclass, but the method that gets called is actually overridden in a subclass it won't stop at your breakpoint. Your best bet is to set a breakpoint just before the method is called and step into it.
posted 15 years ago
In my case the interface method call is made in many places, too many to track down. So I can't tell Eclipse to "set a breakpoint at every implementation of this interface's method"? Is that something an Eclipse plugin could be written to do? Seems like Eclipse has all the information it needs to do this, e.g. it can show all the derived classes of an implementation (Show Type Hierarchy).
That is definitely something an Eclipse plugin could do. However, I don't know that one exists that does. One debugging tip is to find that place where a concrete class (that implements the interface) is created. Then you know which concrete class needs the breakpoint.
In the future, please do start a new thread for a new question. Then you get to pick a subject of your very own!