1

This is a minor annoyance I have when debugging with Eclipse. With "Suspend execution on uncaught exceptions" checked, the debugger will normally suspend a thread right where the exception was thrown. Exceptions on the Event Dispatch Thread, however, cause it to pause on the last line of EventDispatchThread.run(). There is no useful information about what the exception is or what caused it until I resume the thread to allow the stack trace to print to the console.

Debug the following code in Eclipse to demonstrate:

public class SuspendOnUncaughtTest {
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                ((Object) null).toString();
            }
        });
    }
}

And here is what it looks like after the exception is thrown:

Suspended at EventDispatchThread.run() EDIT 10/21/2011: I guess there's nothing weird going on with Eclipse or the Java debugger, it's just that exceptions are caught and rethrown in EventDispatchThread.pumpOneEventForFilters(int). I suppose there's no way to tell Eclipse to "suspend execution on exceptions that are going to be caught and possibly rethrown". Too bad.

kylewm
  • 634
  • 6
  • 21

3 Answers3

1

Is see a similar result in NeteBeans, but Thread.setDefaultUncaughtExceptionHandler() may be useful in this context. There's an example here.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • It is useful to know that NetBeans acts similarly, perhaps the issue is with JPDA and not Eclipse. And thank you for the suggestion, but there is still the same irritating behavior even with an uncaught exception handler. – kylewm Oct 19 '11 at 20:41
0

I had this issue and found something that worked for me.

I am using Kepler, and was able to stop this by going to the breakpoints tab of the debugger perspective and deselecting the checkbox on the EventDispatchThread.

enter image description here

WineGoddess
  • 412
  • 3
  • 11
0

As far as I can tell, there is no solution to this. Eclipse is behaving correctly, the correct behavior is just annoying.

kylewm
  • 634
  • 6
  • 21