devxlogo

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 < 10000; i++) {};		throw new Exception("No line numbers");	}  //  private void runtest()}  //  public class jitest

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.(jitest.java:8)	at jitest.main(jitest.java:4)

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

See also  11 Effective Keyword Research Tools and Techniques
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist