Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.ClassInfo


        final SystemDefinition definition,
        final Context context) {
        try {
            String methodName = methodInfo.getName();
            ClassInfo[] parameters = methodInfo.getParameterTypes();
            ClassInfo returnType = methodInfo.getReturnType();
            ClassInfo[] exceptionTypes = methodInfo.getExceptionTypes();
            final String[] parameterNames = new String[parameters.length];
            final CtClass[] bcelParameterTypes = new CtClass[parameters.length];
            final CtClass[] bcelExceptionTypes = new CtClass[exceptionTypes.length];
            final CtClass javassistReturnType = ctClass.getClassPool().get(returnType.getName());
            if (javassistReturnType == null) {
                return; // we have a constructor => skip
            }
            for (int i = 0; i < parameters.length; i++) {
                bcelParameterTypes[i] = ctClass.getClassPool().get(parameters[i].getName());
View Full Code Here


            }

            byte[] bytecode = context.getInitialBytecode();
            ClassLoader loader = context.getLoader();

            ClassInfo classInfo = AsmClassInfo.getClassInfo(bytecode, loader);

            List definitions = context.getDefinitions();
            ExpressionContext[] ctxs = new ExpressionContext[]{
                new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo),
                new ExpressionContext(PointcutType.CALL, classInfo, classInfo),
View Full Code Here

                super.visitFieldInsn(opcode, className, fieldName, fieldDesc);
                return;
            }

            int joinPointHash = AsmHelper.calculateFieldHash(fieldName, fieldDesc);
            ClassInfo classInfo = AsmClassInfo.getClassInfo(className.replace('/', '.'), m_loader);
            FieldInfo fieldInfo = classInfo.getField(joinPointHash);
            if (fieldInfo == null) {
                // lookup in the class hierarchy
                ClassInfo superClassInfo = classInfo.getSuperClass();
                while (superClassInfo != null) {
                    fieldInfo = superClassInfo.getField(joinPointHash);
                    if (fieldInfo == null) {
                        // go up in the hierarchy
                        superClassInfo = superClassInfo.getSuperClass();
                    } else {
                        break;
                    }
                }
                if (fieldInfo == null) {
View Full Code Here

                super.visitMethodInsn(opcode, calleeClassName, calleeMethodName, calleeMethodDesc);
                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) {
View Full Code Here

        //m_joinPointIndex =
        // TransformationUtil.getJoinPointIndex(klass.getCtClass()); // TODO not
        // thread safe

        final CtClass ctClass = klass.getCtClass();
        ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
       
        if (classFilter(definitions, new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo), ctClass)) {
            return;
        }
        final CtMethod[] methods = ctClass.getDeclaredMethods();
View Full Code Here

        // TransformationUtil.getJoinPointIndex(klass.getCtClass()); //TODO
        // thread safe reentrant
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            final SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.HANDLER, classInfo, classInfo), ctClass)) {
                continue;
            }
            ctClass.instrument(new ExprEditor() {
                public void edit(Handler handlerExpr) throws CannotCompileException {
                    try {
                        CtClass exceptionClass = null;
                        try {
                            exceptionClass = handlerExpr.getType();
                        } catch (NullPointerException e) {
                            return;
                        }
                        CtBehavior where = null;
                        try {
                            where = handlerExpr.where();
                        } catch (RuntimeException e) {
                            // <clinit> access leads to a bug in Javassist
                            where = ctClass.getClassInitializer();
                        }
                        MemberInfo withinMethodInfo = null;
                        if (where instanceof CtMethod) {
                            withinMethodInfo = JavassistMethodInfo.getMethodInfo((CtMethod) where, context.getLoader());
                        } else if (where instanceof CtConstructor) {
                            withinMethodInfo = JavassistConstructorInfo.getConstructorInfo(
                                (CtConstructor) where,
                                context.getLoader());
                        }
                        ClassInfo exceptionClassInfo = JavassistClassInfo.getClassInfo(exceptionClass, context
                                .getLoader());
                        ExpressionContext ctx = new ExpressionContext(
                            PointcutType.HANDLER,
                            exceptionClassInfo,
                            withinMethodInfo);
View Full Code Here

    public void transform(final Context context, final Klass klass) throws Exception {
        List definitions = context.getDefinitions();
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classMetaData = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.ANY, classMetaData, classMetaData), ctClass)) {
                continue;
            }
            JavassistHelper.addStaticClassField(ctClass, context);
            JavassistHelper.addJoinPointManagerField(ctClass, definition, context);
View Full Code Here

    public void transform(final Context context, final Klass klass) throws NotFoundException, CannotCompileException {
        List definitions = context.getDefinitions();
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            final SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.CALL, classInfo, classInfo), ctClass)) {
                return;
            }
            ctClass.instrument(new ExprEditor() {
                public void edit(MethodCall methodCall) throws CannotCompileException {
View Full Code Here

        }
        if (!generateJoinPoint) {
            return;
        }

        ClassInfo calleeClassInfo = JavaClassInfo.getClassInfo(calleeClass);
        ReflectionInfo reflectionInfo = null;

        switch (joinPointType) {
            case JoinPointType.METHOD_EXECUTION_INT:
                reflectionInfo = calleeClassInfo.getMethod(joinPointHash);
                doLoadJoinPoint(
                        joinPointClassName,
                        JoinPointType.METHOD_EXECUTION_INT,
                        PointcutType.EXECUTION,
                        callerClass,
                        callerMethodName,
                        callerMethodDesc,
                        callerMethodModifiers,
                        calleeClass,
                        calleeMemberName,
                        calleeMemberDesc,
                        calleeMemberModifiers,
                        joinPointHash,
                        reflectionInfo,
                        calleeClassInfo
                );
                break;

            case JoinPointType.METHOD_CALL_INT:
                reflectionInfo = calleeClassInfo.getMethod(joinPointHash);
                doLoadJoinPoint(
                        joinPointClassName,
                        JoinPointType.METHOD_CALL_INT,
                        PointcutType.CALL,
                        callerClass,
                        callerMethodName,
                        callerMethodDesc,
                        callerMethodModifiers,
                        calleeClass,
                        calleeMemberName,
                        calleeMemberDesc,
                        calleeMemberModifiers,
                        joinPointHash,
                        reflectionInfo,
                        calleeClassInfo
                );
                break;
            case JoinPointType.FIELD_GET_INT:
                reflectionInfo = calleeClassInfo.getField(joinPointHash);
                doLoadJoinPoint(
                        joinPointClassName,
                        JoinPointType.FIELD_GET_INT,
                        PointcutType.GET,
                        callerClass,
                        callerMethodName,
                        callerMethodDesc,
                        callerMethodModifiers,
                        calleeClass,
                        calleeMemberName,
                        calleeMemberDesc,
                        calleeMemberModifiers,
                        joinPointHash,
                        reflectionInfo,
                        calleeClassInfo
                );
                break;

            case JoinPointType.FIELD_SET_INT:
                reflectionInfo = calleeClassInfo.getField(joinPointHash);
                doLoadJoinPoint(
                        joinPointClassName,
                        JoinPointType.FIELD_SET_INT,
                        PointcutType.SET,
                        callerClass,
                        callerMethodName,
                        callerMethodDesc,
                        callerMethodModifiers,
                        calleeClass,
                        calleeMemberName,
                        calleeMemberDesc,
                        calleeMemberModifiers,
                        joinPointHash,
                        reflectionInfo,
                        calleeClassInfo
                );
                break;

            case JoinPointType.CONSTRUCTOR_EXECUTION_INT:
                reflectionInfo = calleeClassInfo.getConstructor(joinPointHash);
                doLoadJoinPoint(
                        joinPointClassName,
                        JoinPointType.CONSTRUCTOR_EXECUTION_INT,
                        PointcutType.EXECUTION,
                        callerClass,
                        callerMethodName,
                        callerMethodDesc,
                        callerMethodModifiers,
                        calleeClass,
                        calleeMemberName,
                        calleeMemberDesc,
                        calleeMemberModifiers,
                        joinPointHash,
                        reflectionInfo,
                        calleeClassInfo
                );
                break;

            case JoinPointType.CONSTRUCTOR_CALL_INT:
                reflectionInfo = calleeClassInfo.getConstructor(joinPointHash);
                doLoadJoinPoint(
                        joinPointClassName,
                        JoinPointType.CONSTRUCTOR_CALL_INT,
                        PointcutType.CALL,
                        callerClass,
View Full Code Here

                joinPointHash,
                joinPointClassName,
                EmittedJoinPoint.NO_LINE_NUMBER
        );

        ClassInfo callerClassInfo = JavaClassInfo.getClassInfo(callerClass);
        ReflectionInfo withinInfo = null;
        // FIXME: refactor getMethodInfo in INFO so that we can apply it on "<init>" and that it delegates to ctor
        // instead of checking things here.
        switch (joinPointType) {
            case JoinPointType.CONSTRUCTOR_EXECUTION_INT:
                withinInfo = callerClassInfo.getConstructor(AsmHelper.calculateConstructorHash(callerMethodDesc));
                break;
            default:
                // TODO - support for withincode <clinit>
                if (TransformationConstants.INIT_METHOD_NAME.equals(callerMethodName)) {
                    withinInfo = callerClassInfo.getConstructor(AsmHelper.calculateConstructorHash(callerMethodDesc));
                } else {
                    withinInfo =
                    callerClassInfo.getMethod(AsmHelper.calculateMethodHash(callerMethodName, callerMethodDesc));
                }
        }

        final ExpressionContext ctx = new ExpressionContext(pointcutType, reflectionInfo, withinInfo);
        final AdviceInfoContainer adviceContainer = getAdviceInfoContainerForJoinPoint(
View Full Code Here

TOP

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

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.