KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > agent > DefaultAdvice


1 package alt.jiapi.agent;
2
3 import alt.jiapi.util.HotSpotAdvice;
4
5 public class DefaultAdvice extends HotSpotAdvice {
6     public void advice() {
7     // NOTE: For some reason, we get class verify error,
8
// If we store longs into local variables,
9
// when having overlapping hotspots.
10
// Casting into ints before storing into
11
// local variable acts as a workaround for this bug.
12
int l1 = (int)System.currentTimeMillis();
13     
14     doHotSpot();
15
16     int l2 = (int)System.currentTimeMillis();
17     System.out.println("It took " + (l2-l1) + " ms to invoke " +
18         getHotSpotName());
19
20 // Object o = getInstrumentedObject();
21
// if (o instanceof Class) {
22
// System.out.println("Instrumented class is " + o);
23
// }
24
// else {
25
// System.out.println("Instrumented objects' class is " + o.getClass());
26
// }
27
}
28 }
29
Popular Tags