google一下,看到stackoverflow论坛上有关于这种情况的解决办法
英语不好,就没翻译成汉语。
Window > Preferences > Java > Debug : Suspend execution on uncaught exceptions
Why does Eclipse work that way?
It goes back to 2002, when the breakpoint object hierarchy has been stripped down.
In order to set a breakpoint, with the old API, a client required Java Model Objects - such as
IType
,IField
, etc. With the new API, all that is required by the debug model is type names, field names, etc.This allows clients to set breakpoints when Java Model Objects are not available. Clients now specify the resource to associate a breakpoint with (before we constrained it to the associated Java Model resources).
Breakpoints can now also be "hidden". That is, they need not be registered with the breakpoint manager. Breakpoints can also be selectively persisted (markers only allowed all/none of a marker type to be persisted). This makes the debug model more flexible, and gives clients more building blocks.
This has also simplified some part of our Java debug implementation - for example, the feature "
suspend on any uncaught exception
", simply sets a breakpoint for the type named "java.lang.Throwable
", rather than a specificIType
in a specific project. The breakpoint is not registered with the breakpoint manager (i.e. hidden) - it is only known and used by one client. Another example is the "run to line breakpoint
". TheIJavaRunToLineBreakpoint
has been removed, as its special functionality is no longer required. Now, the Java debug ui simply creates a "line breakpoint" that is hidden, non persisted, and has a hit count of 1. This is an example of providing building blocks to clients.-------------------------------------------------------------------------------
That did it! Thank you! Now why does Eclipse even work this way? – skiphoppy Apr 6 '09 at 21:36
It helps detecting those unchecked runtime exception that are uncaught by your code. – VonC Apr 6 '09 at 21:42
I'm encountering the same behaviour and I didn't uncheck "suspend execution on uhncaught exceptions". I prefer to leave the option checked but I would be interested in knowing which exception occurred, how can I know this? – HAL9000 Dec 17 '13 at 11:46
@HAL9000 if you leave that option checked, shouldn't you see which exception is occurring? By "I'm encountering the same behaviour ", do you mean you have "phantom" breakpoints? – VonC Dec 17 '13 at 12:04
Yes I mean phantom breakpoints. Sometimes, in a certain line, a phantom breakpoint is triggered. However neither LogCat, nor Console say anything about exceptions. Also the code seems exception-free, then I was wondering about where to look for an exception message. – HAL9000 Dec 17 '13 at 12:24