This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse breakpoint in class/jar with no source Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse breakpoint in class/jar with no source" Watch "Eclipse breakpoint in class/jar with no source" New topic
Author

Eclipse breakpoint in class/jar with no source

Pratik R Patel
Greenhorn

Joined: Jan 13, 2005
Posts: 5
Here's one for the Eclipse experts:

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?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Pratik,
I'm not sure how to set a breakpoint there, but you can "step into" that code with the debugger. Just press F5 or click the "step into" button when that method is about to execute.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stefan Willi
Ranch Hand

Joined: Mar 11, 2005
Posts: 47
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.

stefan
Pratik R Patel
Greenhorn

Joined: Jan 13, 2005
Posts: 5
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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Pratik,
Thanks for sharing!
Jamshid Afshar
Greenhorn

Joined: Mar 28, 2005
Posts: 3
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.
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
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.
Jamshid Afshar
Greenhorn

Joined: Mar 28, 2005
Posts: 3
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).
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Jamshid,
Welcome to JavaRanch!

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse breakpoint in class/jar with no source
 
Similar Threads
DriverManager.getConnection() not working in runtime but working fine in debug mode of Eclipse
I need to step thru another war that I link to...
Remote debug under ganymede/galileo
How to set breakpoint programmatically under Eclipse?
Debugging Help