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());
}
// push this
il.append(InstructionFactory.createThis());
// push arguments
int index = 1;
for (int i = 0; i < methodArgTypes.length; i++) {
emitLoad(il, index, methodArgTypes[i]);
index += methodArgTypes[i].getSize();
}
// call method
il.append(new INVOKESPECIAL(cp.addMethodref(method.getDeclaringClass()
.getName(), method.getName(), method.getSignature())));
emitReturn(il, methodReturnType);
//
// DONE
//
mg.setMaxStack();
mg.setMaxLocals();
clazz.addMethod(mg.getMethod());
}