?
Solved

how to trace the method calls sequence

Posted on 2004-11-09
9
Medium Priority
?
1,761 Views
Last Modified: 2013-11-23
I have a class like this

public class TestTraceMethods
{
public static void main(String[] args)
{
TestTraceMethods test = new TestTraceMethods();
test.testMe();
Runtime.getRuntime().traceMethodCalls(true);
// Thread.currentThread().dumpStack();
// (new Throwable()).printStackTrace( System.out );
}

public void testMe()
{
System.out.println("Hello World!");
}
}

here JVM is ignoring this--> Runtime.getRuntime().traceMethodCalls(true);

then i refered API

there i found that

Enables/Disables tracing of method calls. If the boolean argument is true, this method suggests that the Java virtual machine emit debugging information for each method in the virtual machine as it is called. The format of this information, and the file or other output stream to which it is emitted, depends on the host environment. The virtual machine may ignore this request if it does not support this feature.


then how can i set host environment to get log file or format of this information.



0
Comment
Question by:chaitu chaitu
  • 5
  • 3
9 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12534144
Tracing only works with the debug version of java apparently....  

Try using 'java_g' instead of 'java'.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12534168
Hehe, I can't find a java_g...so looks like that info was wrong...

is this any better?

public static void main(String[] args)
{
    Runtime.getRuntime().traceMethodCalls(true);
    TestTraceMethods test = new TestTraceMethods();
    test.testMe();
}

ie: turn it on before you do anything?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12534208
>> Try using 'java_g' instead of 'java'.
java -Xdebug
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 35

Expert Comment

by:TimYates
ID: 12534272
Nope...after a bit more research, this flag isn't supported by most JVMs

Apparently you can get (or build?) a debug jvm from Sun which will support it...but by default they do nothing when you turn this on...

What are you trying to do?  Profile your application?  Why not try a java profiler?

http://www.javaworld.com/javaworld/javatips/jw-javatip92.html
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12534403
0
 
LVL 37

Accepted Solution

by:
zzynx earned 2000 total points
ID: 12534545
I read somewhere:

1. I m trying to use java_g / jdb pair in the windows environment.
    I couldn't find java_g in JDK 1.2 package. Was it replaced with something else?
2. I don’t get any output when I do a
      Runtime.traceMethodCalls(true ).
    I was expecting all the function calls to be traced. Does this mean that the JDK doesn’t support this on windows?

Answer: I think they changed this at some point.
             I currently:

             1) Compile everything using: javac -g
             2) Run using:
                     java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 YourClassName

http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/java.html
http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/jdb.html
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12761643
Hi chaituu, what about closing some of your open questions (15)?
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 12761939
i AM SATISFIED with the answers  of some of the questions;

i will update some questions in 2 or 3 days time;

i will replied to some of the questions but not get replies
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12772931
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
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.
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

840 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