new HotSpotLocator(il, new byte[]{Opcodes.GETSTATIC,
Opcodes.GETFIELD});
HotSpot[] hotSpots = hsl.getHotSpots();
for (int i = 0; i < hotSpots.length; i++) {
FieldAccess fa = (FieldAccess)hotSpots[i].getHotSpotInstruction();
short opCode = fa.getOpcode();
if (!match(fa.getClassName() + "." + fa.getFieldName())) {
continue;
}
InstructionList hsList = hotSpots[i].getInstructionList();
InstructionList nList = il.createEmptyList();
boolean primitive = SignatureUtil.isPrimitive(fa.getTypeName());
if (opCode == Opcodes.GETSTATIC ||
opCode == Opcodes.GETFIELD) {
nList.add(factory.getField(interceptor)); // Interceptor
// NOTE: We could store Class into variable,
// and use getField() instead of Class.forName() call
// Class or objref; 1st parameter to interceptor
if (opCode == Opcodes.GETSTATIC) {
short lvIdx =
addClassForNameInstructions(fa.getClassName(), jm);
nList.add(factory.aload(lvIdx));
// addClassForNameInstructions(fa.getClassName(), nList);
// nList.add(factory.pushNull());
}
else {
//addClassForNameInstructions(fa.getClassName(), nList);
nList.add(hsList.get(0)); // objref
}
// Name of the field; 2nd parameter to interceptor
nList.add(factory.pushConstant(fa.getFieldName()));
// 3rd parameter; field value
Instruction pIns = null;
if (primitive) {
// Provide wrapper for primitive types
pIns = handlePrimitiveType(fa.getTypeName(), nList);
}
//nList.add(fa);
//nList.add(hsList);
nList.add(hotSpots[i].getInstructionList());
if (pIns != null) {
nList.add(pIns);
}
// call Interceptor
nList.add(factory.invoke(getMethod));
handleReturnValue(nList, fa.getTypeName());
//nList.add(factory.cast(fa.getTypeName()));
hotSpots[i].getInstructionList()/* hsList*/.replace(nList);
}
}