Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Line numbers/Compiled code in stackTrace.

Posted on 2000-04-06
26
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

730 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