Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse breakpoint in class/jar with no source

 
Pratik R Patel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Willi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pratik,
Thanks for sharing!
 
Jamshid Afshar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic