"Unknown Source" in java stack trace, yet line numbers are in the class file

Found this answer on another question:

This is normally related to missing debug information. You are probably using JRE (not JDK), which does not include debug information for rt.jar classes. Try using full JDK, you'll get proper locations in the stack trace


I had exactly the same problem. In our environment it helped to switch off the optimize-flag:

<javac optimize="off" ...

Apparently Ant does not ignore attribute optimize, although Ant-Doc says for Attribute "optimize" (and we are using Java 1.7):

Indicates whether source should be compiled with optimization; defaults to off. Note that this flag is just ignored by Sun's javac starting with JDK 1.3 (since compile-time optimization is unnecessary).


I think the correct way is:

<javac debug="true" debuglevel="lines,vars,source"

Note there are no spaces between lines,vars,source

Tags:

Java

Ant