Eclipse SWING app: breakpoint hit only after an uncaught exception is thrown
I have a really strange issue. I am working on a Java SWING application in Eclipse. I set a breakpoint somewhere in my code, then run the debug. I execute the piece of code containing the breakpoint but it is always skipped. As soon as I run some code that throws an uncaught exception, the breakpoints start being hit again, without changing anything else. The code that throws the exception and the one containing the breakpoint are not related.
I tried to set the breakpoints in several places but they never get hit until the exception is thrown. I have this problem only for this one specific application. My debugger works fine for other SWING apps.
Can you think of any reason causing this?
What exact version of eclipse and Java are you running?
Are you aware of this question? (bug 279137: Breakpoints fail to hit under JDK 1.6.0_14 )
As gojomo remarks in the comments, that bug (279137) now (July 21 2009) mentions:
The bug is now visible in the sun bug database: bug 6862295 .
We have listed a workaround for this problem, which can be used while we investigate a fix for the bug.
Work Around
Using the option -XX:+UseParallelGC
makes the failure not reproducible with either the Client VM or the Server VM.
(Option yo add to the eclipse.ini)
I would recommend that you use the 'watch this bug' feature, so you can be notified when there are updates to the bug. Here is the link to watch this specific bug
FIXED
As the release note of the jdk6_u16 (late August 2009) mentions, that bug has been fixed
Bug fixed in this release:
6862295 JDWP threadid changes during debugging session (leading to ignored breakpoints)
Have you started the GUI in a seperate thread? I don't recognize your particular problem, but a lot of strange problems disappeared once I started to use this code from the java tutorials :
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
链接地址: http://www.djcxy.com/p/90552.html