dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Intermediate
Apr 16, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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
Brett Spell
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date