InstructionList il;
cp = clazz.getConstantPool();
il = new InstructionList();
InstructionFactory fac = new InstructionFactory(clazz, cp);
Type methodReturnType = translate(method.getReturnType());
Type[] methodArgTypes = translate(method.getParameterTypes());
MethodGen mg = new MethodGen(
Constants.ACC_FINAL | Constants.ACC_PUBLIC, methodReturnType,
methodArgTypes, null, // arg names
method.getName(), clazz.getClassName(), il, cp);
mg.addAttribute(new Synthetic(cp.addUtf8("Synthetic"), 0, null, cp
.getConstantPool()));
Class[] throwsException = method.getExceptionTypes();
for (int i = 0; i < throwsException.length; i++) {
mg.addException(throwsException[i].getName());
}
//
// BODY
//
il.append(InstructionFactory.createThis());
il.append(fac.createGetField(clazz.getClassName(), handlerField
.getName(), handlerField.getType()));
// push "this" as invoke's first argument
il.append(InstructionFactory.createThis());
// load data value
if (dataField.isStatic()) {
il.append(fac.createGetStatic(clazz.getClassName(), dataField
.getName(), dataField.getType()));
} else {
il.append(InstructionFactory.createThis());
il.append(fac.createGetField(clazz.getClassName(), dataField
.getName(), dataField.getType()));
}
il.append(new PUSH(cp, methodArgTypes.length));
il.append((Instruction) fac.createNewArray(Type.OBJECT, (short) 1));
int index = 1;
for (int i = 0; i < methodArgTypes.length; i++) {
// dup array ref
il.append(InstructionConstants.DUP);