1 package samples.hotspot; 2 3 import alt.jiapi.*; 4 import alt.jiapi.util.*; 5 6 import org.apache.log4j.Category; 7 8 public class Sample1 extends HotSpotAdvice { 9 public static void main(String [] args) throws Exception { 10 String className = "samples.Foo"; 11 if (args.length > 0) { 12 className = args[0]; 13 } 14 15 new Sample1(className); 16 } 17 18 19 public Sample1(String className) throws Exception { 20 InstrumentationContext ctx = new InstrumentationContext(); 22 InstrumentationDescriptor id = new InstrumentationDescriptor(); 23 id.addInclusionRule("samples.*"); 24 ctx.addInstrumentationDescriptor(id); 25 26 HotSpotAdvisor hsi = 27 new HotSpotAdvisor(id, this, HotSpotAdvisor.INVOCATIONS); 28 29 Bootstrapper.launch(className, null, ctx, 31 InstrumentingClassLoader.createClassLoader(ctx)); 32 } 33 34 35 43 public void advice() { 44 System.out.println("Calling a method: " + getHotSpotName()); 45 doHotSpot(); 46 System.out.println("Returned from method: " + getHotSpotName()); 47 } 48 } 49 | Popular Tags |