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

Unable to insert breakpoint Absent Line Number Information

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


当前回答

If someone is trying to debug Java's source code, then, this is the only solution that worked for me. Most of the above answers talk about setting the Compiler option to generate line numbers.But, if want to debug Java's source code (say java.util.HashMap), then the above options may not work for you. This is because , the project from where you intend to debug the source code is having the Java Build Path --> Library --> JRE System Library pointing to the jre jar instead of the jdk jar. The classes bundled inside jre jar have already been pre-compiled with a specific option, that will not honor the Compiler option settings. Solution, is to reconfigure your project to have the JRE System Library point to the jdk jar. The classes inside your jdk jar will honour the Compiler option settings. So, once you update your project's JRE System Library to point to the jdk jar, debug on Java source code will start working.

其他回答

If someone is trying to debug Java's source code, then, this is the only solution that worked for me. Most of the above answers talk about setting the Compiler option to generate line numbers.But, if want to debug Java's source code (say java.util.HashMap), then the above options may not work for you. This is because , the project from where you intend to debug the source code is having the Java Build Path --> Library --> JRE System Library pointing to the jre jar instead of the jdk jar. The classes bundled inside jre jar have already been pre-compiled with a specific option, that will not honor the Compiler option settings. Solution, is to reconfigure your project to have the JRE System Library point to the jdk jar. The classes inside your jdk jar will honour the Compiler option settings. So, once you update your project's JRE System Library to point to the jdk jar, debug on Java source code will start working.

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

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

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

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

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

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

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

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

在编译/构建jar时,我做了上面列出的所有事情-仍然有同样的问题。

最终,在启动服务器时,下面列出的jvmarg更改最终为我工作:

删除/注释了一堆与javaagent和bootclasspath相关的jvm参数。

<!-- jvmarg value=“${agentfile}” /-->

< !贾维德- lib /雷丁——>

<!-- jvmarg value=“-Xbootclasspath/a:/foo /-->

打开/取消注释以下行:

<jvmarg value= -Xdebug />

然后,当我启动服务器时,我就可以到达断点了。我怀疑javaagent在某种程度上干扰了Eclipse检测行号的能力。

我在一个特定的项目中遇到了同样的问题,我一直试图重置窗口中的行号属性->首选项…然后我意识到每个项目都有自己的行号属性设置。右键单击项目,进入属性,选择JavaCompiler,并选中“添加行号属性…”

我的情况与此类似:

我正在调试一个JUnit测试 我使用Mockito创建一个间谍,如在spyTask =间谍(new Task()) 我将断点放在我正在监视的类中(在Task.java中)

这个断点会生成问题中的错误,每次我运行Debug As…> JUnit测试

为了解决这个问题,我将断点“向上”移动到实际测试中(在TaskTest.java内部)。一旦执行停止,我将断点添加回原来的位置(在Task.java中)。

我仍然得到相同的错误,但点击“确定”后,断点工作正常。

希望这对大家有所帮助,

-gmale