4

Need to debug a JAR file "ProA", so import the source code in the project, but there is a strange error in Eclipse while trying to set a breakpoint. Detail as below:

Unable to install breakpoint due to missing line number attributes.
Modify compiler options to generate line number attributes.

I have try to several method to solve, but failed.

  1. Under Window > Preferences: Java > Compiler > Classfile Generation, all options have to be to True
  2. In .settings folder of your project, look for a file called org.eclipse.jdt.core.prefs. Verify or set org.eclipse.jdt.core.compiler.debug.lineNumber=generate
  3. Add the debug=true flag in the build.xml, just like this: <javac srcdir="./src/java" destdir="./bin" debug="true">

Any help will be appreciated.

howlger
  • 31,050
  • 11
  • 59
  • 99
Scoket Joe
  • 107
  • 1
  • 2
  • 10

3 Answers3

2

I have had the same problem, but reading your post helped me resolve mine. I changed org.eclipse.jdt.core.prefs as follow:

BEFORE:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

AFTER:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
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.7

Another way to modify these options within the Project> Properties> Java Compiler. So, there is no need to modify manually the org.eclipse.jdt.core.prefs file. There you need to make sure that the Classfile Generation options are checked.

Shadow
  • 8,749
  • 4
  • 47
  • 57
Agostinho
  • 21
  • 2
0

In the JAR the line number attributes are missing in the compiled bytecode. With the added source code Eclipse knows the line numbers, but not the Java VM that executes the bytecode and does not see the source code.

It would be useless if Eclipse told the Java VM to stop at a specific line, because the Java VM does not know which command is in which line and so when to stop.

The only solution is to recreate the JAR or at least the bytecode (.class files) with line information of the class(es) where you want to set a breakpoint.

howlger
  • 31,050
  • 11
  • 59
  • 99
0

****Window -> Preferences -> Compiler **** For debugging we need producing line number in class files. after selecting "Add Line Number attributes to generated class files (used by debugger), rebuild the project and run your debugger to see line numbers and breakpoint, and execution pointer. enter image description here

senerg
  • 51
  • 1