Is it possible to add breakpoints to a class which

2019-04-28 17:58发布

问题:

I want to add a breakpoint in a class in Eclipse, but I don't have the source code for it. Is it possible to add a breakpoint in it anyway? In my case I really only need to know when a method is called.

(As a side note: does anyone have the source code for j2ee_api_1_3.jar?)

回答1:

Download jad decompiler /configure its path in eclipse through windows->preferences and open the source of the class where you need to place the breakpoint - and then debug can run as it does normally and you can see all the variable information in the variable view.



回答2:

If you open the outline view, you can select a method, right-click and select Toggle Method Breakpoint, this will then break whenever the method is hit.

You may be able to get the sources from Sun's archive download page



回答3:

As mentioned by Rich, the outline view (available even without sources):

alt text http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.user/images/ref-8.png

allows you to set method breakpoint, that is, provided javac compiled those classes with debug informations, including "Source Code information" (that is the case with J2EE1.4, not sure about J2EE1.3)

The source code of J2EE 1.3 should be available and be included with the download center j2sdkee-1_3_1-win.exe file.



回答4:

It depends, I think, on whether the class was compiled with debug information. If so, then the class file contains meta-data such as line numbers and parameter names which the debugger needs to make a decent fist of it. If not, then the debugger has less information to go on.

JavaEE libraries are notorious for not having debug meta-data compiled into them. It can be quite frustrating.