Java stack trace with line numbers

Wednesday, 11 February 2004

Often in Java program stack trace, you will see some stack frames include a source line number, while some only say “compiled code”. This is because the stack frames without line numbers have been compiled by the JIT compiler, and the JIT compiler obliterates line number information when it compiles code.

To ensure that source line numbers always appear in stack traces, disable the JIT compiler by running your program with

java -Djava.compiler=NONE blahblahblah...

Now stack traces will show line numbers for each stack frame.

Tags: ,


You can leave a comment, or trackback from your own site.

  1. The downside of this is that the JIT compiler also performs code optimisation. I’ve found some code will run 10 to 20 times slower with the JIT compiler disabled. So, this technique is fine for debugging, but not for production code.

  2. How we can do in RAD – setting this option or compile option -g

Leave a comment