Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.MethodInfo


                )
        );
    }

    public void testWithinCodeType() throws Exception {
        MethodInfo stringtoStringMethod = JavaMethodInfo.getMethodInfo(
                String.class.getDeclaredMethod("toString", new Class[]{})
        );
        MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
        assertTrue(
                new ExpressionInfo(
                        "execution(void test.expression.Target.modifiers1()) AND withincode(void test.expression.Target.modifiers1())",
                        NAMESPACE
                ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, method))
View Full Code Here


                    getInitialModel().getEmittedJoinPoint();
            final ClassLoader loader = clazz.getClassLoader();

            final ClassInfo calleeClassInfo = AsmClassInfo.getClassInfo(joinPoint.getCalleeClassName(), loader);
            final ClassInfo callerClassInfo = AsmClassInfo.getClassInfo(joinPoint.getCallerClassName(), loader);
            final MethodInfo callerMethodInfo = getCallerMethodInfo(callerClassInfo, joinPoint);

            ExpressionContext ctx = null;
            switch (joinPoint.getJoinPointType()) {
                case JoinPointType.METHOD_EXECUTION_INT:
                    ctx = new ExpressionContext(
View Full Code Here

     * @param emittedJoinPoint
     * @return
     */
    private static MethodInfo getCallerMethodInfo(final ClassInfo callerClassInfo,
                                                  final EmittedJoinPoint emittedJoinPoint) {
        MethodInfo callerMethodInfo = null;
        MethodInfo[] callerMethods = callerClassInfo.getMethods();
        for (int i = 0; i < callerMethods.length; i++) {
            MethodInfo method = callerMethods[i];
            if (method.getName().equals(emittedJoinPoint.getCallerMethodName()) &&
                method.getSignature().equals(emittedJoinPoint.getCallerMethodDesc())) {
                callerMethodInfo = method;
                break;
            }
        }
        return callerMethodInfo;
View Full Code Here

     * @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;
            }

View Full Code Here

            }

            int joinPointHash = AsmHelper.calculateMethodHash(calleeMethodName, calleeMethodDesc);

            ClassInfo classInfo = AsmClassInfo.getClassInfo(calleeClassName, m_loader);
            MethodInfo calleeMethodInfo = classInfo.getMethod(joinPointHash);

            if (calleeMethodInfo == null) {
                System.err.println(
                        "AW::WARNING " +
                        "metadata structure could not be build for method ["
                        + classInfo.getName().replace('/', '.')
                        + '.' + calleeMethodName + ':' + calleeMethodDesc
                        + "] when parsing method ["
                        + m_callerClassInfo.getName() + '.' + m_callerMethodName + "(..)]"
                );
                // bail out
                super.visitMethodInsn(opcode, calleeClassName, calleeMethodName, calleeMethodDesc);
                return;
            }

            ExpressionContext ctx = new ExpressionContext(PointcutType.CALL, calleeMethodInfo, m_callerMemberInfo);

            if (methodFilter(m_ctx.getDefinitions(), ctx, calleeMethodInfo)) {
                super.visitMethodInsn(opcode, calleeClassName, calleeMethodName, calleeMethodDesc);
            } else {
                m_ctx.markAsAdvised();

                String joinPointClassName = TransformationUtil.getJoinPointClassName(
                        m_callerClassName,
                        m_callerMethodName,
                        m_callerMethodDesc,
                        calleeClassName,
                        JoinPointType.METHOD_CALL_INT,
                        joinPointHash
                );

                // load the caller instance (this), or null if in a static context
                // note that callee instance [optional] and args are already on the stack
                if (Modifier.isStatic(m_callerMemberInfo.getModifiers())) {
                    visitInsn(ACONST_NULL);
                } else {
                    visitVarInsn(ALOAD, 0);
                }

                // add the call to the join point
                super.visitMethodInsn(
                        INVOKESTATIC,
                        joinPointClassName,
                        INVOKE_METHOD_NAME,
                        TransformationUtil.getInvokeSignatureForCodeJoinPoints(
                                calleeMethodInfo.getModifiers(), calleeMethodDesc,
                                m_callerClassName, calleeClassName
                        )
                );

                // emit the joinpoint
                //See AW-253 - we remember if we had an INVOKE INTERFACE opcode
                int modifiers = calleeMethodInfo.getModifiers();
                if (opcode == INVOKEINTERFACE) {
                    modifiers = modifiers | MODIFIER_INVOKEINTERFACE;
                }
                m_ctx.addEmittedJoinPoint(
                        new EmittedJoinPoint(
View Full Code Here

            //TODO filter on synthetic method ?
            return super.visitMethod(access, name, desc, exceptions, attrs);
        }

        int hash = AsmHelper.calculateMethodHash(name, desc);
        MethodInfo methodInfo = m_classInfo.getMethod(hash);
        if (methodInfo == null) {
            throw new Error(
                    "method info metadata structure could not be build for method: " + m_declaringTypeName + '.' +
                    name +
                    ':' +
View Full Code Here

            return true;
        }
        if (!(o instanceof MethodInfo)) {
            return false;
        }
        MethodInfo methodInfo = (MethodInfo) o;
        if (!m_declaringType.getName().toString().equals(methodInfo.getDeclaringType().getName().toString())) {
            return false;
        }
        if (!m_member.getName().toString().equals(methodInfo.getName().toString())) {
            return false;
        }
        Class[] parameterTypes1 = ((Method) m_member).getParameterTypes();
        ClassInfo[] parameterTypes2 = methodInfo.getParameterTypes();
        if (parameterTypes1.length != parameterTypes2.length) {
            return false;
        }
        for (int i = 0; i < parameterTypes1.length; i++) {
            if (!parameterTypes1[i].getName().toString().equals(parameterTypes2[i].getName().toString())) {
View Full Code Here

            return true;
        }
        if (!(o instanceof MethodInfo)) {
            return false;
        }
        MethodInfo methodInfo = (MethodInfo) o;
        if (!m_declaringType.getName().toString().equals(methodInfo.getDeclaringType().getName().toString())) {
            return false;
        }
        if (!m_member.name.equals(methodInfo.getName().toString())) {
            return false;
        }
        ClassInfo[] parameterTypes = methodInfo.getParameterTypes();
        if (m_parameterTypes.length != parameterTypes.length) {
            return false;
        }
        for (int i = 0; i < m_parameterTypes.length; i++) {
            if (!m_parameterTypes[i].getName().toString().equals(parameterTypes[i].getName().toString())) {
View Full Code Here

                MethodSignatureImpl methodSignature = new MethodSignatureImpl(
                    methodTuple.getDeclaringClass(),
                    methodTuple);
                tuple.signature = methodSignature;
                tuple.rtti = new MethodRttiImpl(methodSignature, thisInstance, targetInstance);
                MethodInfo methodInfo = JavaMethodInfo.getMethodInfo(methodTuple.getWrapperMethod());
                ClassInfo withinInfo = JavaClassInfo.getClassInfo(targetClass);
                ExpressionContext ctx = new ExpressionContext(PointcutType.EXECUTION, methodInfo, methodInfo);//AVAJ
                for (int i = 0; i < aspectManagers.length; i++) {
                    for (Iterator it = aspectManagers[i].getPointcuts(ctx).iterator(); it.hasNext();) {
                        Pointcut pointcut = (Pointcut) it.next();
View Full Code Here

            name.startsWith(WRAPPER_METHOD_PREFIX)) {//TODO filter on synthetic method ?
            return cv.visitMethod(access, name, desc, exceptions, attrs);
        }

        int hash = AsmHelper.calculateMethodHash(name, desc);
        MethodInfo methodInfo = m_classInfo.getMethod(hash);
        if (methodInfo == null) {
            throw new Error("method info metadata structure could not be build for method: " + name + " " + desc);
        }

        ExpressionContext ctx = new ExpressionContext(PointcutType.EXECUTION, methodInfo, methodInfo);
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.reflect.MethodInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.