// if the bytecode is a field access
if (op == Opcode.PUTFIELD || op == Opcode.GETFIELD) {
int val = it.s16bitAt(index + 1);
// if the field access is for an added field
if (fieldAccessLocations.containsKey(val)) {
AddedFieldData data = fieldAccessLocations.get(val);
int arrayPos = file.getConstPool().addIntegerInfo(data.getArrayIndex());
// write over the field access with nop
it.writeByte(Opcode.NOP, index);
it.writeByte(Opcode.NOP, index + 1);
it.writeByte(Opcode.NOP, index + 2);
if (op == Opcode.PUTFIELD) {
Bytecode b = new Bytecode(file.getConstPool());
if (data.getDescriptor().charAt(0) != 'L' && data.getDescriptor().charAt(0) != '[') {
Boxing.box(b, data.getDescriptor().charAt(0));
}
b.addLdc(arrayPos);
b.addInvokestatic(FIELD_DATA_STORE_CLASS, "setValue", "(Ljava/lang/Object;Ljava/lang/Object;I)V");
it.insertEx(b.get());
} else if (op == Opcode.GETFIELD) {
Bytecode b = new Bytecode(file.getConstPool());
b.addLdc(arrayPos);
b.addInvokestatic(FIELD_DATA_STORE_CLASS, "getValue", "(Ljava/lang/Object;I)Ljava/lang/Object;");
if (DescriptorUtils.isPrimitive(data.getDescriptor())) {
Boxing.unbox(b, data.getDescriptor().charAt(0));
} else {
b.addCheckcast(DescriptorUtils.getTypeStringFromDescriptorFormat(data.getDescriptor()));
}
it.insertEx(b.get());
}
}