Eclipse / Java:EDT中的未捕获异常在EventDispatchThread.run()中暂停执行 [英] Eclipse/Java: uncaught exceptions on the EDT suspend execution in EventDispatchThread.run()

查看:242
本文介绍了Eclipse / Java:EDT中的未捕获异常在EventDispatchThread.run()中暂停执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是使用Eclipse进行调试时遇到的小问题。选中暂停执行未捕获的异常后,调试器通常会在引发异常的情况下挂起一个线程。但是,事件调度线程的异常导致它在EventDispatchThread.run()的最后一行上暂停。在我恢复线程以允许堆栈跟踪打印到控制台之前,没有关于异常是什么或引起什么的有用信息。

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.

在Eclipse中调试以下代码来演示:

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:


编辑10/21/2011:我想没有什么奇怪的事情与Eclipse或Java调试器,只是异常被捕获和重新抛出在EventDispatchThread.pumpOneEventForFilters(int)。我想没有办法告诉Eclipse暂停执行将被捕获并可能被重新引导的异常。太糟糕了。

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.

推荐答案

据我所知,没有办法解决这个问题。 Eclipse行为正确,正确的行为只是令人讨厌。

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

这篇关于Eclipse / Java:EDT中的未捕获异常在EventDispatchThread.run()中暂停执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆