1 18 19 package alt.jiapi.instrumentor; 20 21 import java.util.ArrayList ; 22 import java.util.List ; 23 24 import alt.jiapi.JiapiException; 25 import alt.jiapi.Rule; 26 import alt.jiapi.Runtime; 27 import alt.jiapi.reflect.Instruction; 28 import alt.jiapi.reflect.InstructionList; 29 30 import alt.jiapi.reflect.instruction.Invocation; 31 import alt.jiapi.reflect.instruction.OpcodeGroups; 32 33 42 public class MethodCallStrategy extends AbstractStrategy { 43 public MethodCallStrategy() { 44 this("*"); 45 } 46 47 51 public MethodCallStrategy(String matcher) { 52 super(matcher); 53 } 54 55 60 public MethodCallStrategy(String [] matchers, boolean reverse) { 61 super(matchers, reverse); 62 } 63 64 73 public List findHotSpots(InstructionList il) { 74 List hotSpots = new ArrayList (); 75 int index = 0; 76 77 while ((index = il.indexOf(OpcodeGroups.INVOKE_INSTRUCTIONS, 79 index)) != -1) { 80 Invocation ins = (Invocation)il.get(index); 83 String targetName = ins.getClassName() + "." + ins.getMethodName(); 84 if (match(targetName)) { 87 Instrumentation i = getInstrumentation(); 88 i.setTargetName(targetName); 90 HotSpot h = new HotSpot(index, index + 1); 91 hotSpots.add(h); 92 } 93 94 index++; 95 } 96 97 return hotSpots; 98 } 99 } 100 | Popular Tags |