/* BTrace Script Template */ import com.sun.btrace.annotations.*; import static com.sun.btrace.BTraceUtils.*; @BTrace public class TracingScript { /* put your code here */ @OnMethod( clazz = "mypackage.BTraceTest", method = "init", location = @Location(Kind.RETURN)) public static void func(@Self mypackage.BTraceTest instance, @Return String result){ println(" Call Stack "); // jstack(); //println(strcat(" Parameter A ", str(a))); //println(strcat(" Parameter B ", str(b))); println(strcat(" Parameter Result ", str(result))); } }
package mypackage; import java.io.BufferedReader; import java.io.InputStreamReader; public class BTraceTest { public int add(int a, int b){ return a + b; } public static void main(String args[]) throws Exception{ BTraceTest test = new BTraceTest(); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); for(int i = 0; i < 1000; i++){ reader.readLine(); // int a = (int)Math.round(Math.random() * 1000); // int b = (int)Math.round(Math.random() * 1000); // System.out.println(test.add(a, b)); System.out.println(test.init()); } } public String init(){ return "init"; } }