methodVisitor.visitVarInsn(ALOAD, 0);
final Class<?>[] parameterTypes = method.getParameterTypes();
final int numberOfParams = parameterTypes.length;
int paramSize = 0;
for (int paramIndex = 0; paramIndex < numberOfParams; paramIndex++) {
final Type type = Type.getType(parameterTypes[paramIndex]);
final int opcode = type.getOpcode(ILOAD);
methodVisitor.visitVarInsn(opcode, paramSize + 1);
paramSize += type.getSize();
}
final Type returnType = Type.getReturnType(method);
methodVisitor.visitMethodInsn(
/**/INVOKESPECIAL,
/**/superClassInternalName,
/**/methodName,
/**/desc);
methodVisitor.visitLabel(label1);
int opcode;
if (!Type.VOID_TYPE.equals(returnType)) {
opcode = returnType.getOpcode(ISTORE);
methodVisitor.visitVarInsn(opcode, paramSize + 1);
}
methodVisitor.visitVarInsn(ALOAD, 0);
methodVisitor.visitMethodInsn(
/**/INVOKEVIRTUAL,
/**/classInternalName,
/**/METHOD_END_METHOD_NAME,
/**/methodEndMethodDesc);
if (!Type.VOID_TYPE.equals(returnType)) {
opcode = returnType.getOpcode(ILOAD);
methodVisitor.visitVarInsn(opcode, paramSize + 1);
}
opcode = returnType.getOpcode(IRETURN);
methodVisitor.visitInsn(opcode);
// finally block
methodVisitor.visitLabel(label2);
methodVisitor.visitVarInsn(ASTORE, 1);