且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我的 Eclipse 项目有幻像调试器断点?

更新时间:2023-09-18 23:02:40

您是否尝试取消选择

窗口 >首选项 >爪哇>调试:暂停执行未捕获的异常

?(如 ,当断点对象层次结构已被剥离.

为了设置断点,使用旧 API,客户端需要 Java 模型对象 - 例如 ITypeIField
使用新 API,调试模型所需的只是类型名称、字段名称等.

这允许客户端在 Java 模型对象不可用时设置断点.
客户端现在指定要与断点关联的资源(在我们将其限制为关联的 Java 模型资源之前).

断点现在也可以隐藏".也就是说,它们不需要在断点管理器中注册.
断点也可以有选择地保留(标记只允许保留所有/全部标记类型).
这使得调试模型更加灵活,并为客户提供更多构建块.

这也简化了我们的 Java 调试实现的某些部分 - 例如,功能暂停任何未捕获的异常",只需为名为的类型设置断点java.lang.Throwable",而不是特定项目中的特定IType.
断点未在断点管理器中注册(即隐藏) - 只有一个客户端知道和使用它.
另一个例子是run to line breakpoint".IJavaRunToLineBreakpoint 已被删除,因为不再需要它的特殊功能.现在,Java 调试 ui 只是创建一个隐藏的、非持久化的、命中数为 1 的行断点".这是向客户端提供构建块的示例.

I've got a small project which, when run in the Eclipse debugger, always seems to stop in FileInputStream.class line 106, where files are opened. There are no breakpoints set, but Eclipse behaves exactly as if I have a breakpoint here. If I clear all breakpoints, it still happens.

I have a second much-larger project in the same Eclipse workspace which does not suffer from this problem.

I just moved the smaller project off of my old Linux machine, where I developed it in Europa Eclipse and had this problem, onto my new Windows machine, where I continue to see the problem in Ganymede Eclipse. The problem persists across operating systems and across Eclipse versions, yet apparently not across projects. I don't get it! I grepped through every file in this project's directory and couldn't find anything that might be a file somehow directing Eclipse to stop in FileInputStream.

Further info: the apparent breakpoint is actually not for line 106 of FileInputStream; it appears to be an Exception breakpoint for FileNotFoundException, being thrown from native code called from that line in FileInputStream. But again, I don't appear to have any breakpoints set at all. Are Exception breakpoints defined somewhere else?

Did you try to un-select

Window > Preferences > Java > Debug : Suspend execution on uncaught exceptions

? (as mentioned in this thread, for instance)

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 specific IType 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". The IJavaRunToLineBreakpoint 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.