Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.MethodInfo


            List interfaceDeclaredMethods = ClassInfoHelper.collectMethodsFromInterfacesImplementedBy(mixinClass);
            List sortedMethodList = ClassInfoHelper.createInterfaceDefinedMethodList(
                    mixinClass, interfaceDeclaredMethods
            );
            for (Iterator iterator = sortedMethodList.iterator(); iterator.hasNext();) {
                MethodInfo methodInfo = (MethodInfo) iterator.next();
                m_methodsToIntroduce.add(methodInfo);
            }
        }

        m_mixinImplClassName = mixinClass.getName();
View Full Code Here


    private ClassInfo defineSystemMixin(final ClassLoader loader) {
        // if advisable impl mixin get the class info from the AsmClassInfo to keep the methods starting with aw$
        ClassInfo mixinClass = AsmClassInfo.getClassInfo(AdvisableImpl.class.getName(), loader);
        MethodInfo[] methods = mixinClass.getMethods();
        for (int i = 0; i < methods.length; i++) {
            MethodInfo method = methods[i];
            if (method.getName().startsWith(TransformationConstants.SYNTHETIC_MEMBER_PREFIX)) {
                m_methodsToIntroduce.add(method);
            }
        }
        m_interfaceClassNames.add(Advisable.class.getName());
        return mixinClass;
View Full Code Here

     *
     * @param hash
     * @return
     */
    public MethodInfo getMethod(final int hash) {
        MethodInfo method = (MethodInfo) m_methods.get(hash);
        if (method == null) {
            for (int i = 0; i < getInterfaces().length; i++) {
                method = getInterfaces()[i].getMethod(hash);
                if (method != null) {
                    break;
View Full Code Here

        }
    }

    public Object visit(ASTMethodPattern node, Object data) {
        if (data instanceof MethodInfo) {
            MethodInfo methodInfo = (MethodInfo) data;
            if (node.getMethodNamePattern().matches(methodInfo.getName())
                && node.getDeclaringTypePattern().matchType(methodInfo.getDeclaringType())
                && node.getReturnTypePattern().matchType(methodInfo.getReturnType())
                && visitAttributes(node, methodInfo)
                && visitModifiers(node, methodInfo)
                && visitParameters(node, methodInfo.getParameterTypes())) {
                return Boolean.TRUE;
            }
        }

        return Boolean.FALSE;
View Full Code Here

     *
     * @param hash
     * @return
     */
    public MethodInfo getMethod(final int hash) {
        MethodInfo method = (MethodInfo) m_methods.get(hash);
        if (method == null) {
            for (int i = 0; i < getInterfaces().length; i++) {
                method = getInterfaces()[i].getMethod(hash);
                if (method != null) {
                    break;
View Full Code Here

        Map annotationElementValueHoldersByName = new HashMap();

        // populate with the default values (might be then overriden by setted values)
        MethodInfo[] annotationMethods = annotationClassInfo.getMethods();
        for (int i = 0; i < annotationMethods.length; i++) {
            MethodInfo annotationMethod = annotationMethods[i];
            for (Iterator iterator = annotationMethod.getAnnotations().iterator(); iterator.hasNext();) {
                AnnotationInfo annotationInfo = (AnnotationInfo) iterator.next();
                // handles AnnotationDefault attribute that we have wrapped. See AnnotationDefault.
                if (annotationInfo.getName().equals(AnnotationDefault.NAME)) {
                    Object value = ((AnnotationDefault)annotationInfo.getAnnotation()).value();
                    Object valueHolder = getAnnotationValueHolder(value, loader);
                    annotationElementValueHoldersByName.put(annotationMethod.getName(),
                                                            new AnnotationElement(annotationMethod.getName(),
                                                                                  valueHolder)
                    );
                }
            }
        }
View Full Code Here

    public Object visit(ASTMethodPattern node, Object data) {

        if (data instanceof MethodInfo) {

            MethodInfo methodInfo = (MethodInfo) data;

            if (node.getMethodNamePattern().matches(methodInfo.getName())

                && ClassInfoHelper.matchType(node.getDeclaringTypePattern(), methodInfo.getDeclaringType())

                && ClassInfoHelper.matchType(node.getReturnTypePattern(), methodInfo.getReturnType())

                && visitAttributes(node, methodInfo)

                && visitModifiers(node, methodInfo)

                && visitParameters(node, methodInfo.getParameterTypes())) {

                return Boolean.TRUE;

            }
View Full Code Here

        for (Iterator it = introductionDefs.iterator(); it.hasNext();) {
            IntroductionDefinition introDef = (IntroductionDefinition) it.next();
            int methodIndex = 0;
            List methodsToIntroduce = introDef.getMethodsToIntroduce();
            for (Iterator mit = methodsToIntroduce.iterator(); mit.hasNext(); methodIndex++) {
                MethodInfo methodToIntroduce = (MethodInfo) mit.next();
                if (methodToIntroduce == null) {
                    continue;
                }
                createProxyMethod(
                    ctClass,
View Full Code Here

                name.startsWith("access$")) {//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

                return;
            }

            int joinPointHash = AsmHelper.calculateMethodHash(calleeMethodName, calleeMethodDesc);
            ClassInfo classInfo = AsmClassInfo.getClassInfo(calleeClassName.replace('/', '.'), m_loader);
            MethodInfo calleeMethodInfo = classInfo.getMethod(joinPointHash);
            if (calleeMethodInfo == null) {
                // lookup in the class hierarchy
                ClassInfo superClassInfo = classInfo.getSuperClass();
                while (superClassInfo != null) {
                    calleeMethodInfo = superClassInfo.getMethod(joinPointHash);
                    if (calleeMethodInfo == null) {
                        // go up in the hierarchy
                        superClassInfo = superClassInfo.getSuperClass();
                    } else {
                        break;
                    }
                }
                if (calleeMethodInfo == null) {
                    throw new Error(
                            "callee method info metadata structure could not be build for method: "
                            + calleeClassName
                            + '.'
                            + calleeMethodName
                            + ':'
                            + calleeMethodDesc
                    );
                }
            }

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

            if (methodFilter(m_ctx.getDefinitions(), ctx, calleeMethodInfo)) {
                super.visitMethodInsn(opcode, calleeClassName, calleeMethodName, calleeMethodDesc);
            } else {
                m_ctx.markAsAdvised();
                m_sequence++; // single place of incrementation, is used in multiple places

                // TODO is caller class sufficient in the name or do we need callee classname?
                String joinPointClassName = JoinPointCompiler.getJoinPointClassName(
                        m_callerClassName,
                        JoinPointType.METHOD_CALL,
                        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_callerMethodInfo.getModifiers())) {
                    visitInsn(ACONST_NULL);
                } else {
                    visitVarInsn(ALOAD, 0);
                }

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

                // emit the joinpoint
                m_ctx.addEmittedInlinedJoinPoint(
                        new ContextImpl.EmittedInlinedJoinPoint(
                                JoinPointType.METHOD_CALL,
                                m_callerClassName,
                                m_callerMethodName,
                                m_callerMethodDesc,
                                m_callerMethodInfo.getModifiers(),
                                calleeClassName,
                                calleeMethodName,
                                calleeMethodDesc,
                                calleeMethodInfo.getModifiers(),
                                m_sequence,
                                joinPointHash,
                                joinPointClassName
                        )
                );
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.