Solved

Line numbers/Compiled code in stackTrace.

Posted on 2000-04-06
26
207 Views
Last Modified: 2013-11-23
Why does myException.printStackTrace() sometimes shows the line number of line where the exception was thrown and other times it says "Compiled Code"? Is there a way to make it always show/not show the line number?
0
Comment
Question by:Sasha_Mapa
  • 10
  • 6
  • 4
  • +3
26 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 2691255
you have to turn off the JIT compiler

java -nojit myClass
for 1.1

1.2 syntax was more coplicated - something like (I really can't remember it now :(
java -Djit.compiler=off
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 50 total points
ID: 2691260
.. docs ...

USING JIT COMPILERS
By default, the Java application launcher runs applications on the Java HotSpot virtual machine implementation. Just-in-time (JIT) compilers cannot be used in conjunction with Java HotSpot because the HotSpot architecture makes use of it's own optimizing compiler.
Applications can optionally be launched using the classic virtual machine by using the -classic option.
java -classic MyApp
In this mode, the JAVA_COMPILER environment variable can be used to specify a JIT compiler to use in conjunction with the classic VM. The .dll files for JIT compilers should be located in the directory jre\bin in the SDK, and in the bin directory in the Java 2 Runtime Environment). If the JIT compiler's file is named foo.dll, for example, setting JAVA_COMPILER equal to "foo", would cause the Java launcher to invoke the foo JIT compiler when running applications in classic mode. A JIT compiler may also be invoked when launching an application on the classic VM by setting the java.compiler property with a command-line switch:
java -classic -Djava.compiler=foo MyApp


I suppose that the option you need is
java -Djava.compiler=none MyApp

0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2691261
umm, what about applets (I'm testing in appletviewer)? When exactly do I turn off the JIT compiler? when executing my application with "java"?
0
 
LVL 7

Expert Comment

by:conick
ID: 2691262
1.1 doesnt have JIT installed by default.

1.2 is:
java -Djava.compiler=NONE <classname>

1.3 doesnt have the JIT installed by default.
0
 
LVL 7

Expert Comment

by:conick
ID: 2691265
whoops ;) ..
heyhey is quick on the trigger :)
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2691298
just passing ... :)
-D option should work with appletviewer too ...
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2691503
Ok, sorry, I'm a bit confused here.
What I don't understand is when do I type that? When compiling? but I compile with "javac", "java" executes the application!
When running? but I run it with appletviewer which doesn't take "-Djava.compiler=NONE as a valid switch!
0
 
LVL 4

Expert Comment

by:adam923
ID: 2691514
did you compile the class with the -g option to generate debug info?
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2691531
Ok, I have now - still says "Compiled code" in my classes.
0
 
LVL 4

Expert Comment

by:adam923
ID: 2691554
what options did you give appletviewer?
-JDjava.compiler=NONE should work because -J tells appletviewer to take the following param and pass it off to the java vm... i haven't tried it but it's worth a shot
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2691569
it says Exception in thread "main" java.lang.NoClassDefFoundError: Djava/compile=NONE
0
 
LVL 5

Expert Comment

by:mbormann
ID: 2691942
this maybe off track but just fyi ,In IE 4.0 & I think 5.0 you can switch off JIT compiler.
:)
0
 
LVL 4

Expert Comment

by:adam923
ID: 2692388
how about trying
appletviewer -J-Djava.compiler=NONE Applet.html
I've seen this syntax in the discussion groups on java.sun.com buy I haven't tried it myself
0
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.

 

Expert Comment

by:dharshan
ID: 2693234
Use option  appletviewer -J -Djava.compiler=NONE ....
It works
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2693341
Thanks for the offer, dharshan, but people proposed this before you did.
I can't check if it works right now, I'll be able to only on Sunday.
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2697625
adam923, it doesn't work either, still says "Compiled code" in all my methods, though it says the line number in all of the java methods (like java.awt.Component.dispatchEventImpl)
Please help! :-)
0
 
LVL 5

Expert Comment

by:mbormann
ID: 2697958
Sasha,

May solve ur prob, look at this ,I think I had participated here but I don't remember,

http://www1.experts-exchange.com/bin/Q.10212756
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2697972
Ok, now I've just wasted 10 points...I need to disable this for appletviewer and none of the commands proposed above works...
0
 
LVL 5

Expert Comment

by:mbormann
ID: 2698184
sorry I cant recall exactly if it was for appletviewer but I thought it would be usefule for you

:(
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2698604
appletviewer -J-nojit main.html works for 1.1 ... don't have 1.2 installed here, so I can't try it.
0
 
LVL 4

Expert Comment

by:adam923
ID: 2698727
appletviewer -J-Djava.compiler=NONE Applet.html
works in jdk1.2.2 (standard), i just tried it... what version are you on sasha?
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2699085
heyhey: Ok, I'll try that too.
adam: 1.2 - How are you sure it actually works? Did you try a piece of code
that otherwise gives a (Compiled code) exception?

Unfortunately, I'm going away until Friday, so I won't be able to test anything or reply to you until then...
0
 
LVL 4

Expert Comment

by:adam923
ID: 2699092
no, what i meant by "it works" was that it ran my applet with, presumably, no JIT enabled.  sorry that i wasn't clear on that... if i get time to and remember before friday i'll add a method that throws a null pointer exception and test it out
0
 
LVL 4

Expert Comment

by:adam923
ID: 2705552
Sasha: I tired it and it works fine for me...
here's my test code...
//This is Test.java
public class Test extends java.applet.Applet {
      public void start(){
            while(true)
                  work();
      }
      private void work(){
            for(int i = 0; i < 1000; i++)
                  ;
            if(Math.random() < .01)
                  throw new NullPointerException();
      }
}
//end of Test.java
<!--This is Test.html>
<applet code = "Test.class" height=100 width=100></applet>
<!-- End of Test.html>
Transcript of my command prompt session for testing:

C:\>appletviewer Test.html
java.lang.NullPointerException
        at Test.work(Test.java, Compiled Code)
        at Test.start(Test.java, Compiled Code)
        at sun.applet.AppletPanel.run(AppletPanel.java:347)
        at java.lang.Thread.run(Thread.java:479)

C:\>appletviewer -J-Djava.compiler=NONE Test.html
java.lang.NullPointerException
        at Test.work(Test.java:10)
        at Test.start(Test.java:4)
        at sun.applet.AppletPanel.run(AppletPanel.java:347)
        at java.lang.Thread.run(Thread.java:479)

Using jdk 1.2.2 (standard) and nt 4.0 workstation... not that it should matter.
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2717845
adam, I'll post a question for you to answer too.
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 2717846
Let's just hope this works at work as well as it works on my computer at home....
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

746 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

10 Experts available now in Live!

Get 1:1 Help Now