在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。

Unable to insert breakpoint Absent Line Number Information

我勾选了编译器选项的复选框,但运气不好。


当前回答

我从黑莓SDK方面得到了这个问题的答案:出于某种原因,无论我在编译器中修改了多少次选项,实际的底层设置文件都没有改变。

在项目的.settings文件夹中查找一个名为org.eclipse.jdt.core.prefs的文件。

在那里你可以手动修改设置:

org.eclipse.jdt.core.compiler.debug.lineNumber=generate

编辑:除此之外,我还注意到有时我可以忽略Eclipse给出的警告,它仍然会停在需要的地方……越来越奇怪……我将此归入我们作为开发人员所需要处理的事情中。

其他回答

因为我安装了6个不同版本的Java,所以我必须更改默认的JDK遵从性,以匹配我想使用的Java版本。当所有内容都使用Java 1.6构建/编译时,Eclipse默认将编译器遵从级别设置为Java 1.7。

所以我所做的就是

在eclipse菜单中,进入“窗口->首选项->Java->编译器” 在JDK遵从性下,我将编译器遵从性级别从1.7更改为1.6

现在Eclipse不再抱怨“无法插入缺少行号信息的断点”,并且调试断点实际上工作了!!

如果您确实指出了您正在使用的eclipse版本和技术(例如,Java JDT,或面向Java的AJDT,或c++ CDT),这将有所帮助。

在Java方面,我猜想您的“勾选编译器选项中的复选框”指的就是这个

在“窗口—>首选项—> Java—>编译器—>类文件生成”下,所有“类文件”生成选项都设置为True:

(1)添加可变属性, (2) addline number, (3)添加源文件名, (4)保存未使用的局部变量。

您的项目是否只在全局级别(windows Preferences)或在项目特定级别检查这些?

你确定打开的类(你试图在上面设置断点):

是您的源代码之一(并且不是来自第三方库) 是。java,而不是。class?

尝试清理所有内容并重新构建所有内容,检查潜在的jar冲突。

在eclipse菜单中,进入“窗口->首选项->Java->编译器” 取消标记复选框“添加行号属性…” 单击“应用”->是 标记复选框“添加行号属性…” 再次申请。 愉快调试

我试图调试日志管理器,需要将jre更改为jdk,然后在“主”选项卡中选择这个jdk,调试配置的“Java运行时环境”|“运行时jre”,然后一切正常。

这里有详细的解释:

https://github.com/spring-projects/spring-ide/issues/78

只是为了将来参考,这是答案的相关部分(忽略引用Spring Boot应用程序的事实,在许多其他情况下行为是相同的):

Whenever you set a breakpoint in Eclipse/STS, the IDE tries to set the breakpoint in the VM if you launch an app. That is what happens in your case when you run the boot app in debug mode. For each class that gets loaded into the JVM, the IDE checks whether it needs to set a breakpoint or not. If it decides to set the breakpoint, the tries to do so (using the information from the breakpoint definition in the IDE, including its line number, since you usually set line breakpoints on a source file at a given line). This decision (whether to set the breakpoint on a given loaded class or not) checks the types that you set the breakpoint on, enclosing types, and inner classes. This makes sure that breakpoints for inner classes (even anonymous inner classes) are set to the JVM (and are not ignored). Spring Boot generates an inner class for your controller at runtime (this is the CGLIB generated inner class that appears in the error message). When the JVM loads that class, it tries to set the line number breakpoint of the enclosing type (for this inner class). Since the generated inner class doesn't have any line number information (it doesn't need to have line number information), setting the breakpoint fails for this inner class with the mentioned error message. When the IDE loads the enclosing type (your controller class itself), it also tries to set the line breakpoint and succeeds with that. This is visualized with the check marker on the breakpoint marker. Therefore you can safely ignore the error message that shows up. To avoid this error message to show up, you can go to the preferences (Java -> Debug) and disable "Warn when unable to install breakpoint due to missing line number attributes".