Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.FieldInfo


    }

    // ============ pointcut type tests =============
    public void testPointcutTypes() throws Exception {
        MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
        FieldInfo field = JavaFieldInfo.getFieldInfo(Target.class.getDeclaredField("modifier1"));
        assertTrue(
                new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.EXECUTION, method, null))
        );
        assertFalse(
View Full Code Here


            }

            final Type fieldType = Type.getType(fieldDesc);
            final int joinPointHash = AsmHelper.calculateFieldHash(fieldName, fieldDesc);
            final ClassInfo classInfo = AsmClassInfo.getClassInfo(className, m_loader);
            final FieldInfo fieldInfo = getFieldInfo(classInfo, className, fieldName, fieldDesc, joinPointHash);

            if (opcode == PUTFIELD || opcode == PUTSTATIC) {
                handleFieldModification(fieldInfo, opcode, className, fieldName, fieldDesc, joinPointHash);
            } else if (opcode == GETFIELD || opcode == GETSTATIC) {
                handleFieldAccess(fieldInfo, opcode, className, fieldName, fieldDesc, joinPointHash, fieldType);
View Full Code Here

        private FieldInfo getFieldInfo(final ClassInfo classInfo,
                                       final String className,
                                       final String fieldName,
                                       final String fieldDesc,
                                       final int joinPointHash) {
            FieldInfo fieldInfo = classInfo.getField(joinPointHash);
            if (fieldInfo == null) {
                // lookup in the class hierarchy
                ClassInfo superClassInfo = classInfo.getSuperclass();
                while (superClassInfo != null) {
                    fieldInfo = superClassInfo.getField(joinPointHash);
View Full Code Here

            fieldName.equals(SERIAL_VERSION_UID_FIELD_NAME)) {  // can have been added by the weaver (not safe)
            return;
        }

        int joinPointHash = AsmHelper.calculateFieldHash(fieldName, fieldDesc);
        FieldInfo fieldInfo = getFieldInfo(m_classInfo, m_declaringTypeName, fieldName, fieldDesc, joinPointHash);

        ExpressionContext[] ctxs = new ExpressionContext[]{
            new ExpressionContext(PointcutType.SET, fieldInfo, null),
            new ExpressionContext(PointcutType.GET, fieldInfo, null)//TODO are we sure that within=null means match
        };
View Full Code Here

    private FieldInfo getFieldInfo(final ClassInfo classInfo,
                                   final String className,
                                   final String fieldName,
                                   final String fieldDesc,
                                   final int joinPointHash) {
        FieldInfo fieldInfo = classInfo.getField(joinPointHash);
        if (fieldInfo == null) {
            // lookup in the class hierarchy
            ClassInfo superClassInfo = classInfo.getSuperclass();
            while (superClassInfo != null) {
                fieldInfo = superClassInfo.getField(joinPointHash);
View Full Code Here

            return true;
        }
        if (!(o instanceof FieldInfo)) {
            return false;
        }
        FieldInfo fieldInfo = (FieldInfo) o;
        if (!m_declaringTypeName.equals(fieldInfo.getDeclaringType().getName())) {
            return false;
        }
        if (!m_member.name.equals(fieldInfo.getName())) {
            return false;
        }
        if (!m_typeName.equals(fieldInfo.getType().getName())) {
            return false;
        }
        return true;
    }
View Full Code Here

            return true;
        }
        if (!(o instanceof FieldInfo)) {
            return false;
        }
        FieldInfo fieldInfo = (FieldInfo) o;
        if (!m_declaringType.getName().equals(fieldInfo.getDeclaringType().getName())) {
            return false;
        }
        if (!m_member.getName().equals(fieldInfo.getName())) {
            return false;
        }
        ClassInfo fieldType = fieldInfo.getType();
        if (!m_type.getName().equals(fieldType.getName())) {
            return false;
        }
        return true;
    }
View Full Code Here

            FieldInfo[] fields = classInfo.getFields();
            if (fields != null) {
                Arrays.sort(
                        fields, new Comparator() {
                            public int compare(Object o1, Object o2) {
                                FieldInfo field1 = (FieldInfo) o1;
                                FieldInfo field2 = (FieldInfo) o2;
                                return field1.getName().compareTo(field2.getName());
                            }
                        }
                );
                for (int i = 0; i < fields.length; i++) {
                    FieldInfo field = fields[i];
                    int mods = field.getModifiers();
                    if (((mods & Constants.ACC_PRIVATE) == 0) ||
                        ((mods & (Constants.ACC_STATIC |
                                  Constants.ACC_TRANSIENT)) == 0)) {
                        out.writeUTF(field.getName());
                        out.writeInt(mods & filterSynthetic());
                        out.writeUTF(field.getSignature());
                    }
                }
            }

            // handle static initialization.
View Full Code Here

     * @return the annotation or null
     */
    public static Annotation getAnnotation(final String annotationName, final Field field) {
        ClassLoader loader = field.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(field.getDeclaringClass().getName(), loader);
        FieldInfo fieldInfo = classInfo.getField(ReflectHelper.calculateHash(field));
        return AsmAnnotations.getAnnotation(annotationName, fieldInfo);
    }
View Full Code Here

     * @return the annotations in a list (can be empty)
     */
    public static List getAnnotations(final String annotationName, final Field field) {
        ClassLoader loader = field.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(field.getDeclaringClass().getName(), loader);
        FieldInfo fieldInfo = classInfo.getField(ReflectHelper.calculateHash(field));
        return AsmAnnotations.getAnnotations(annotationName, fieldInfo);
    }
View Full Code Here

TOP

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

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.