Eclipse SWING应用程序:仅在抛出未捕获的异常后才会触发断点

时间:2022-05-22 22:56:45

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.

我有一个非常奇怪的问题。我正在Eclipse中使用Java SWING应用程序。我在代码中的某处设置了一个断点,然后运行调试。我执行包含断点的代码段,但总是跳过它。一旦我运行了一些抛出未捕获异常的代码,断点就会再次被触发,而不会改变其他任何东西。抛出异常的代码和包含断点的代码不相关。

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.

我尝试在几个地方设置断点,但在抛出异常之前它们永远不会被击中。我只针对这个特定的应用程序有这个问题。我的调试器适用于其他SWING应用程序。

Can you think of any reason causing this?

你能想出造成这种情况的原因吗?

2 个解决方案

#1


What exact version of eclipse and Java are you running?

你正在运行什么样的eclipse和Java版本?

Are you aware of this question? (bug 279137: Breakpoints fail to hit under JDK 1.6.0_14 )

你知道这个问题吗? (错误279137:断点无法在JDK 1.6.0_14下命中)


As gojomo remarks in the comments, that bug (279137) now (July 21 2009) mentions:

正如gojomo在评论中所言,该错误(279137)现在(2009年7月21日)提到:

The bug is now visible in the sun bug database: bug 6862295.

现在可以在sun bug数据库中看到该错误: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.

使用选项-XX:+ UseParallelGC使客户端VM或服务器VM无法重现该故障。

(Option yo add to the eclipse.ini)

(选项哟添加到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

正如jdk6_u16(2009年8月下旬)的发布说明所提到的,该错误已被修复

Bug fixed in this release:

此版本中修复了错误:

6862295 JDWP threadid changes during debugging session (leading to ignored breakpoints)

6862295 JDWP threadid在调试会话期间发生更改(导致忽略断点)

#2


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 :

你是否在一个单独的线程中启动了GUI?我不认识你的特殊问题,但是一旦我开始使用java教程中的代码,很多奇怪的问题就消失了:

SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        createAndShowGUI();
    }
});

#1


What exact version of eclipse and Java are you running?

你正在运行什么样的eclipse和Java版本?

Are you aware of this question? (bug 279137: Breakpoints fail to hit under JDK 1.6.0_14 )

你知道这个问题吗? (错误279137:断点无法在JDK 1.6.0_14下命中)


As gojomo remarks in the comments, that bug (279137) now (July 21 2009) mentions:

正如gojomo在评论中所言,该错误(279137)现在(2009年7月21日)提到:

The bug is now visible in the sun bug database: bug 6862295.

现在可以在sun bug数据库中看到该错误: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.

使用选项-XX:+ UseParallelGC使客户端VM或服务器VM无法重现该故障。

(Option yo add to the eclipse.ini)

(选项哟添加到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

正如jdk6_u16(2009年8月下旬)的发布说明所提到的,该错误已被修复

Bug fixed in this release:

此版本中修复了错误:

6862295 JDWP threadid changes during debugging session (leading to ignored breakpoints)

6862295 JDWP threadid在调试会话期间发生更改(导致忽略断点)

#2


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 :

你是否在一个单独的线程中启动了GUI?我不认识你的特殊问题,但是一旦我开始使用java教程中的代码,很多奇怪的问题就消失了:

SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        createAndShowGUI();
    }
});