/** Creates the 'invoke' method. */ protected void createInvokeMethod() { String invokeDesc = buildInvokeMethodSignature(); MethodVisitor cv = m_cw.visitMethod( ACC_PUBLIC + ACC_FINAL + ACC_STATIC, INVOKE_METHOD_NAME, invokeDesc, null, new String[] {THROWABLE_CLASS_NAME}); AsmHelper.loadArgumentTypes(cv, Type.getArgumentTypes(invokeDesc), true); cv.visitMethodInsn( INVOKESTATIC, m_redefinedModel.getJoinPointClassName(), INVOKE_METHOD_NAME, invokeDesc); AsmHelper.addReturnStatement(cv, Type.getReturnType(invokeDesc)); cv.visitMaxs(0, 0); }
/** * Adds the mixin methods to the target class. * * @param fieldInfo * @param mixinDef */ private void addMixinMethods(final MixinFieldInfo fieldInfo, final MixinDefinition mixinDef) { for (Iterator it3 = mixinDef.getMethodsToIntroduce().iterator(); it3.hasNext(); ) { MethodInfo methodInfo = (MethodInfo) it3.next(); final String methodName = methodInfo.getName(); final String methodSignature = methodInfo.getSignature(); if (m_addedMethods.contains( AlreadyAddedMethodVisitor.getMethodKey(methodName, methodSignature))) { continue; } MethodVisitor mv = cv.visitMethod(ACC_PUBLIC + ACC_SYNTHETIC, methodName, methodSignature, null, null); if (fieldInfo.isStatic) { mv.visitFieldInsn( GETSTATIC, m_declaringTypeName, fieldInfo.fieldName, fieldInfo.mixinClassInfo.getSignature()); } else { mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn( GETFIELD, m_declaringTypeName, fieldInfo.fieldName, fieldInfo.mixinClassInfo.getSignature()); } AsmHelper.loadArgumentTypes(mv, Type.getArgumentTypes(methodSignature), false); mv.visitMethodInsn( INVOKEVIRTUAL, fieldInfo.mixinClassInfo.getName().replace('.', '/'), methodName, methodSignature); AsmHelper.addReturnStatement(mv, Type.getReturnType(methodSignature)); mv.visitMaxs(0, 0); } }