if (op == CodeIterator.INVOKESPECIAL) {
int val = it.s16bitAt(index + 1);
// if the method call is one of the methods we are
// replacing
if (methodCallLocations.containsKey(val)) {
ConstructorRewriteData data = methodCallLocations.get(val);
// so we currently have all the arguments sitting on the
// stack, and we need to jigger them into
// an array and then call our method. First thing to do
// is scribble over the existing
// instructions:
it.writeByte(CodeIterator.NOP, index);
it.writeByte(CodeIterator.NOP, index + 1);
it.writeByte(CodeIterator.NOP, index + 2);
Bytecode bc = new Bytecode(file.getConstPool());
ManipulationUtils.pushParametersIntoArray(bc, data.getMethodDesc());
// so now our stack looks like unconstructed instance :
// array
// we need unconstructed instance : int : array : null
bc.addIconst(data.getMethodNo());
bc.add(Opcode.SWAP);
bc.add(Opcode.ACONST_NULL);
bc.addInvokespecial(data.getClazz(), "<init>", Constants.ADDED_CONSTRUCTOR_DESCRIPTOR);
// and we have our bytecode
it.insert(bc.get());
}
}