Solved

printStackTrace...

Posted on 1998-11-17
8
174 Views
Last Modified: 2011-09-20
I have begun to use JDK1.2 and have noticed that the printStackTrace command no longer prints the line numbers for a java file.  It now prints "Compiled Code".

Can anyone help me with this?  I have listed the output from the Stack Trace below.

Thank you in advance.

Stack Trace = java.lang.Throwable
        at com.fmr.fiis.fts.util.Syslog.buildLogHeaderCompiled Code)
        at
com.fmr.fiis.fts.util.Syslog.syslog(Compiled Code)
        at
com.fmr.fiis.fts.util.Syslog.log(Compiled Code)
        at
com.fmr.fiis.fts.util.DbConnect.printDriverInfo(Compiled Code)
        at
com.fmr.fiis.fts.util.DbConnect.getDbConnection(Compiled Code)
        at
com.fmr.fiis.fts.util.FtsCore.DbInit(Compiled Code)
        at
com.fmr.fiis.fts.util.FtsCore.<init>(Compiled Code)
        at Udl3.<init>(Compiled Code)
        at Udl3.main(Compiled Code)
0
Comment
Question by:jefftk
  • 4
  • 3
8 Comments
 
LVL 7

Accepted Solution

by:
conick earned 70 total points
ID: 1227649

run the interpreter without the JIT compiler
like this:

java -Djava.compiler=NONE classname
0
 
LVL 4

Expert Comment

by:evijay
ID: 1227650
give

javac -g classname

during compilation


0
 

Author Comment

by:jefftk
ID: 1227651
OK. I will give it a try.  My question is what has changed in 1.2 to cause this problem?

Evijay,  
I have already tried your solution and it does not work.
0
 

Author Comment

by:jefftk
ID: 1227652
Thank you Conick!  It works fine.
I do have a question, by using that option at run time what are the drawbacks.  Does the code run more slowly?  etc...
Thanks again!
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Expert Comment

by:conick
ID: 1227653

The change in 1.2 is that the JIT (Just in Time) Compiler is defaulted to be on
In 1.1 if you had a JIT compiler (i dont believe it was included...you had to get it in a separate download) you had to specify that you were going to use it.

The JIT compiler converts the Java byte code into platform-dependent machine code so that once the app is loaded it will run faster.
So the only drawback that I can see is that it will run slower...
I only use the -D flag when debugging (and need to see the line numbers) after that there is no real reason to use the flag unless you are having problems with the JIT compiler


0
 

Author Comment

by:jefftk
ID: 1227654
Thanks.
The reason i need it is because i have created a Syslog class to log messages to a log.  I use the line numbers when printing the message so you can see exactly where in the program the message originated.
Do you know of a better way this can be done?  Does JDK1.2 have a feature like this ?
0
 
LVL 7

Expert Comment

by:conick
ID: 1227655
I dont know of any feature like that.
Although there could be one... I havent even scratched the surface
of what 1.2 can do.

You may want to catch the errors and try to use a method from the
Throwable interface (like getMessage() or toString()) to see if you
can get a String representation of the error (and grab the line numbers
from there)
Once you have a string representation you can plop that out to file



0
 

Author Comment

by:jefftk
ID: 1227656
Adjusted points to 75
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now