Line Numbers Missing From Stack Trace

Line Numbers Missing From Stack Trace

You may have seen “(Compiled Code)” in a stack trace and wondered why a line number was not displayed instead. This occurs because as of release 1.1.5 of the Java Development Kit (JDK), the default behavior is to use a Just-In-Time (JIT) compiler. Once the JIT compiler has processed the code, the line numbers no longer exist and cannot be displayed. For example:

 public class jitest {	public static void main(String[] args)					throws Exception {		jitest jt = new jitest();	}  //  public static void main()	public jitest() throws Exception {		runtest();	}  //  public jitest()	private void runtest() throws Exception {		for (int i = 0; i 

Running this code with the Java Virtual Machine (JVM) from 1.1.5 or later will produce this stack trace when the exception is thrown:

 java.lang.Exception: No line numbers	at java.lang.Throwable.(Compiled Code)	at jitest.runtest(Compiled Code)	at jitest.(	at jitest.main(

Notice that the stack trace does not identify the specific line where the exception was thrown, but merely reads "(Compiled Code)". In this trivial example, it's obvious where the exception was generated, but in a more complex class, it can be very difficult to determine where, for example, a NullPointerException occurred. To get around this behavior, you can temporarily disable the JIT using a command-line option. For a Java 1.1.x JVM, use the


Share the Post: