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

Unable to insert breakpoint Absent Line Number Information

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


当前回答

在Eclipse中调试时如何修复断点错误? 只替换这几行。

    eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

其他回答

我在Eclipse 3.4.1中有相同的错误消息,SUN JVM1.6.0_07连接到Tomcat 6.0(在另一台机器上以调试模式运行,SUN JVM1.6.0_16,调试连接正常工作)。

窗口——>首选项——> Java——>编译器——>类文件生成:“添加行号属性生成类文件”被选中。我做了一个干净的重新编译。我取消检查,重新编译,检查,重新编译。我确保项目使用了全局设置。还是一样的信息。

我切换到蚂蚁构建,使用

<javac srcdir="./src/java" destdir="./bin" debug="true">

同样的信息。

我不知道是什么导致了这条消息,为什么它不会消失。尽管这似乎与正在运行的Tomcat调试会话有关:当断开连接时,重新编译可以解决问题。但是在将调试器连接到Tomcat或在连接的调试会话期间设置新的断点时,它又会出现。

然而,事实证明消息是错误的:我确实能够在调试之前和调试期间调试和设置断点(javap -l也显示了行号)。所以请忽略它:)

这里有详细的解释:

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".

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.

如果其他方法都不起作用,打开调试透视图,清除所有现有的断点,然后重新设置它们。

如果上述解决方案不起作用,并且你在做了spring bean注入后开始遇到这个问题,问题可能是你没有为注入类使用接口。尝试使用实现接口的类进行注入可以解决这个问题。下面是一个例子: 无法安装用于创建bean的断点问题