|
Java™ by example!
|
|
|
How can I see line numbers in a stack trace?
You can disable the JIT (Just in Time):
java -Djava.compiler=NONE MyApp
appletviewer -J-Djava.compiler=NONE MyApplet.html
eg. look at the following bug in the code:
When you run this code using "java Main" you will get the following error message:
What line is the bug in? "Compiled Code" doesn't give us much of a clue... Even though most of you coders don't need the line number in this example, it may be useful to have more information (ie. line number) to find a bug in a more complex situation. Run the code using "java -Djava.compiler=NONE Main" and you get
Note that HotSpot is able to product line numbers for JIT'd code.
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|