]> source.dussan.org Git - aspectj.git/commitdiff
improved annotation handling on ResolvedMemberImpl
authoraclement <aclement>
Mon, 26 Apr 2010 23:41:21 +0000 (23:41 +0000)
committeraclement <aclement>
Mon, 26 Apr 2010 23:41:21 +0000 (23:41 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java
org.aspectj.matcher/src/org/aspectj/weaver/Member.java
org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java

index 0191591d5d28710cf45a8711ce617880733fb049..70f58be9af45ff7396f49cfffc92a4c631904a60 100644 (file)
@@ -38,6 +38,8 @@ import org.aspectj.weaver.AjAttribute.EffectiveSignatureAttribute;
  */
 public class JoinPointSignature implements ResolvedMember {
 
+       public static final JoinPointSignature[] EMPTY_ARRAY = new JoinPointSignature[0];
+
        private ResolvedMember realMember;
        private ResolvedType substituteDeclaringType;
 
@@ -200,7 +202,7 @@ public class JoinPointSignature implements ResolvedMember {
        }
 
        public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters, ResolvedType newDeclaringType,
-                       boolean isParameterized, List aliases) {
+                       boolean isParameterized, List<String> aliases) {
                return realMember.parameterizedWith(typeParameters, newDeclaringType, isParameterized, aliases);
        }
 
@@ -224,7 +226,7 @@ public class JoinPointSignature implements ResolvedMember {
                return realMember.resolve(world);
        }
 
-       public int compareTo(Object other) {
+       public int compareTo(Member other) {
                return realMember.compareTo(other);
        }
 
index 85e02ad9b41961c2a775ea9f3e634c740b0c9b2f..8134e8df2f612c6da4fea8fd2144a92fe6641f62 100644 (file)
@@ -1,27 +1,26 @@
 /* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- *               2005 Contributors
+ * Copyright (c) 2002-2010
  * All rights reserved. 
  * This program and the accompanying materials are made available 
  * under the terms of the Eclipse Public License v1.0 
  * which accompanies this distribution and is available at 
  * http://www.eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
- *     PARC     initial implementation
- *     AMC      extracted as interface 
  * ******************************************************************/
 package org.aspectj.weaver;
 
 import java.util.Collection;
 
 /**
- * Abstract representation of a member within a type.
+ * Abstract representation of a member (field/constructor/method) within a type.
+ * 
+ * @author PARC
+ * @author Adrian Colyer
+ * @author Andy Clement
  */
-public interface Member extends Comparable {
+public interface Member extends Comparable<Member> {
 
        public static final Member[] NONE = new Member[0];
-       
+
        public static final MemberKind METHOD = new MemberKind("METHOD", 1);
        public static final MemberKind FIELD = new MemberKind("FIELD", 2);
        public static final MemberKind CONSTRUCTOR = new MemberKind("CONSTRUCTOR", 3);
@@ -45,10 +44,13 @@ public interface Member extends Comparable {
        public UnresolvedType getDeclaringType();
 
        public UnresolvedType[] getParameterTypes();
+
        public UnresolvedType[] getGenericParameterTypes();
 
        public UnresolvedType getType();
+
        public UnresolvedType getReturnType();
+
        public UnresolvedType getGenericReturnType();
 
        /**
@@ -86,6 +88,6 @@ public interface Member extends Comparable {
 
        public ResolvedMember resolve(World world);
 
-       public int compareTo(Object other);
+       public int compareTo(Member other);
 
 }
\ No newline at end of file
index b34c34946faf3d2f264e13f9a295f89705d98c9c..64ae458d21ed94bcbc9ea55afc3d77cc2baa9abc 100644 (file)
@@ -155,7 +155,7 @@ public class MemberImpl implements Member {
        private static Object[] signatureToTypes(String sig) {
                boolean hasParameters = sig.charAt(1) != ')';
                if (hasParameters) {
-                       List l = new ArrayList();
+                       List<UnresolvedType> l = new ArrayList<UnresolvedType>();
                        int i = 1;
                        boolean hasAnyAnglies = sig.indexOf('<') != -1;
                        while (true) {
@@ -211,7 +211,7 @@ public class MemberImpl implements Member {
                                        l.add(UnresolvedType.forSignature(sig.substring(start, i)));
                                }
                        }
-                       UnresolvedType[] paramTypes = (UnresolvedType[]) l.toArray(new UnresolvedType[l.size()]);
+                       UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[l.size()]);
                        UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length()));
                        return new Object[] { returnType, paramTypes };
                } else {
@@ -305,8 +305,8 @@ public class MemberImpl implements Member {
                return hashCode;
        }
 
-       public int compareTo(Object other) {
-               Member o = (Member) other;
+       public int compareTo(Member other) {
+               Member o = other;
                int i = getName().compareTo(o.getName());
                if (i != 0) {
                        return i;
@@ -483,14 +483,14 @@ public class MemberImpl implements Member {
                return b;
        }
 
-       private boolean walkUpStatic(Collection acc, ResolvedType curr) {
+       private boolean walkUpStatic(Collection<ResolvedType> acc, ResolvedType curr) {
                if (curr.lookupMemberNoSupers(this) != null) {
                        acc.add(curr);
                        return true;
                } else {
                        boolean b = false;
-                       for (Iterator i = curr.getDirectSupertypes(); i.hasNext();) {
-                               b |= walkUpStatic(acc, (ResolvedType) i.next());
+                       for (Iterator<ResolvedType> i = curr.getDirectSupertypes(); i.hasNext();) {
+                               b |= walkUpStatic(acc, i.next());
                        }
                        if (!b && curr.isParameterizedType()) {
                                b = walkUpStatic(acc, curr.getGenericType());
index 93d1361a5cf83a9699b85e87b95c92011ddb0838..ffeedbbc3aaf8bccf44affb1c7838d6b17b25f7c 100644 (file)
@@ -126,9 +126,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
        public boolean equalsApartFromDeclaringType(Object other);
 
        // return a resolved member in which all type variables in the signature of
-       // this
-       // member have been replaced with the given bindings.
-       // the isParameterized flag tells us whether we are creating a raw type
+       // this member have been replaced with the given bindings. the isParameterized flag tells us whether we are creating a raw type
        // version or not
        // if isParameterized List<T> will turn into List<String> (for example),
        // but if !isParameterized List<T> will turn into List.
@@ -140,7 +138,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
        // this is used for processing ITDs that share type variables with their
        // target generic type
        public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters, ResolvedType newDeclaringType,
-                       boolean isParameterized, List aliases);
+                       boolean isParameterized, List<String> aliases);
 
        public void setTypeVariables(TypeVariable[] types);
 
@@ -154,7 +152,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
 
        public void evictWeavingState();
 
-       public ResolvedMember parameterizedWith(Map m, World w);
+       public ResolvedMember parameterizedWith(Map<String, UnresolvedType> m, World w);
 
        public boolean isDefaultConstructor();
 
index 3890488d0beffde028ad363076866b0a980a867d..c63c8a09c16c31eea8d1143ec78b5b509de2e51b 100644 (file)
@@ -1,15 +1,11 @@
 /* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2002-2010 Contributors
  * All rights reserved. 
  * This program and the accompanying materials are made available 
  * under the terms of the Eclipse Public License v1.0 
  * which accompanies this distribution and is available at 
  * http://www.eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
- *     PARC     initial implementation 
  * ******************************************************************/
-
 package org.aspectj.weaver;
 
 import java.io.DataOutputStream;
@@ -26,31 +22,35 @@ import java.util.Set;
 import org.aspectj.bridge.ISourceLocation;
 
 /**
- * This is the declared member, i.e. it will always correspond to an actual method/... declaration
+ * Represent a resolved member. Components of it are expected to exist. This member will correspond to a real member *unless* it is
+ * being used to represent the effect of an ITD.
+ * 
+ * @author PARC
+ * @author Andy Clement
  */
 public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, AnnotatedElement, TypeVariableDeclaringElement,
                ResolvedMember {
 
        private String[] parameterNames = null;
        protected UnresolvedType[] checkedExceptions = UnresolvedType.NONE;
+
        /**
         * if this member is a parameterized version of a member in a generic type, then this field holds a reference to the member we
         * parameterize.
         */
        protected ResolvedMember backingGenericMember = null;
 
-       protected Set<ResolvedType> annotationTypes = null;
+       protected AnnotationAJ[] annotations = null;
+       protected ResolvedType[] annotationTypes = null;
+       protected AnnotationAJ[][] parameterAnnotations = null;
        protected ResolvedType[][] parameterAnnotationTypes = null;
 
        // Some members are 'created' to represent other things (for example ITDs).
-       // These
-       // members have their annotations stored elsewhere, and this flag indicates
-       // that is
-       // the case. It is up to the caller to work out where that is!
+       // These members have their annotations stored elsewhere, and this flag indicates
+       // that is the case. It is up to the caller to work out where that is!
        // Once determined the caller may choose to stash the annotations in this
        // member...
-       private boolean isAnnotatedElsewhere = false; // this field is not
-       // serialized.
+       private boolean isAnnotatedElsewhere = false;
        private boolean isAjSynthetic = false;
 
        // generic methods have type variables
@@ -106,7 +106,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                ResolvedType originalDeclaringType = joinPointSignature.getDeclaringType().resolve(inAWorld);
                ResolvedMemberImpl firstDefiningMember = (ResolvedMemberImpl) joinPointSignature.resolve(inAWorld);
                if (firstDefiningMember == null) {
-                       return new JoinPointSignature[0];
+                       return JoinPointSignature.EMPTY_ARRAY;
                }
                // declaringType can be unresolved if we matched a synthetic member
                // generated by Aj...
@@ -116,7 +116,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                ResolvedType firstDefiningType = firstDefiningMember.getDeclaringType().resolve(inAWorld);
                if (firstDefiningType != originalDeclaringType) {
                        if (joinPointSignature.getKind() == Member.CONSTRUCTOR) {
-                               return new JoinPointSignature[0];
+                               return JoinPointSignature.EMPTY_ARRAY;
                        }
                        // else if (shadowMember.isStatic()) {
                        // return new ResolvedMember[] {firstDefiningMember};
@@ -288,10 +288,14 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                        }
                        return backingGenericMember.hasAnnotation(ofType);
                }
-               if (annotationTypes == null) {
-                       return false;
+               if (annotationTypes != null) {
+                       for (int i = 0, max = annotationTypes.length; i < max; i++) {
+                               if (annotationTypes[i].equals(ofType)) {
+                                       return true;
+                               }
+                       }
                }
-               return annotationTypes.contains(ofType);
+               return false;
        }
 
        public ResolvedType[] getAnnotationTypes() {
@@ -305,10 +309,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                        }
                        return backingGenericMember.getAnnotationTypes();
                }
-               if (annotationTypes == null) {
-                       return null;
-               }
-               return annotationTypes.toArray(new ResolvedType[] {});
+               return annotationTypes;
        }
 
        public String getAnnotationDefaultValue() {
@@ -324,20 +325,11 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                return super.getAnnotations();
        }
 
-       public void setAnnotationTypes(ResolvedType[] annotationtypes) {
-               if (annotationTypes == null) {
-                       annotationTypes = new HashSet<ResolvedType>();
-               }
-               for (int i = 0; i < annotationtypes.length; i++) {
-                       ResolvedType typeX = annotationtypes[i];
-                       annotationTypes.add(typeX);
-               }
+       public void setAnnotationTypes(ResolvedType[] annotationTypes) {
+               this.annotationTypes = annotationTypes;
        }
 
        public ResolvedType[][] getParameterAnnotationTypes() {
-               if (parameterAnnotationTypes == null) {
-                       return null;
-               }
                return parameterAnnotationTypes;
        }
 
@@ -350,12 +342,23 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
        }
 
        public void addAnnotation(AnnotationAJ annotation) {
-               // FIXME asc only allows for annotation types, not instances - should
-               // it?
                if (annotationTypes == null) {
-                       annotationTypes = new HashSet<ResolvedType>();
+                       annotationTypes = new ResolvedType[1];
+                       annotationTypes[0] = annotation.getType();
+                       annotations = new AnnotationAJ[1];
+                       annotations[0] = annotation;
+               } else {
+                       int len = annotations.length;
+                       AnnotationAJ[] ret = new AnnotationAJ[len + 1];
+                       System.arraycopy(annotations, 0, ret, 0, len);
+                       ret[len] = annotation;
+                       annotations = ret;
+
+                       ResolvedType[] newAnnotationTypes = new ResolvedType[len + 1];
+                       System.arraycopy(annotationTypes, 0, newAnnotationTypes, 0, len);
+                       newAnnotationTypes[len] = annotation.getType();
+                       annotationTypes = newAnnotationTypes;
                }
-               annotationTypes.add(annotation.getType());
        }
 
        public boolean isBridgeMethod() {
@@ -670,14 +673,14 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
         * turn into List<String> (for example) - if (!isParameterized) then List<T> will turn into List.
         */
        public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters, ResolvedType newDeclaringType,
-                       boolean isParameterized, List aliases) {
+                       boolean isParameterized, List<String> aliases) {
                // PR308773
                // this check had problems for the inner type of a generic type because the inner type can be represented
-               // by a 'simple type' if it is only sharing type variables with the outer and has none of its own.  To avoid the
+               // by a 'simple type' if it is only sharing type variables with the outer and has none of its own. To avoid the
                // check going bang in this case we check for $ (crap...) - we can't check the outer because the declaring type
-               // is considered unresolved...          
+               // is considered unresolved...
                if (// isParameterized && <-- might need this bit...
-               !getDeclaringType().isGenericType()  && getDeclaringType().getName().indexOf("$")==-1) {
+               !getDeclaringType().isGenericType() && getDeclaringType().getName().indexOf("$") == -1) {
                        throw new IllegalStateException("Can't ask to parameterize a member of non-generic type: " + getDeclaringType()
                                        + "  kind(" + getDeclaringType().typeKind + ")");
                }
@@ -703,8 +706,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                // the same value as the type variables real name.
                if (aliases != null) {
                        int posn = 0;
-                       for (Iterator iter = aliases.iterator(); iter.hasNext();) {
-                               String typeVariableAlias = (String) iter.next();
+                       for (String typeVariableAlias : aliases) {
                                typeMap.put(typeVariableAlias, (!typeParametersSupplied ? typeVariables[posn].getFirstBound()
                                                : typeParameters[posn]));
                                posn++;
@@ -732,7 +734,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
         * Replace occurrences of type variables in the signature with values contained in the map. The map is of the form
         * A=String,B=Integer and so a signature List<A> Foo.m(B i) {} would become List<String> Foo.m(Integer i) {}
         */
-       public ResolvedMember parameterizedWith(Map m, World w) {
+       public ResolvedMember parameterizedWith(Map<String, UnresolvedType> m, World w) {
                // if (//isParameterized && <-- might need this bit...
                // !getDeclaringType().isGenericType()) {
                // throw new IllegalStateException(
@@ -802,14 +804,15 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                return typeVariables;
        }
 
-       protected UnresolvedType parameterize(UnresolvedType aType, Map typeVariableMap, boolean inParameterizedType, World w) {
+       protected UnresolvedType parameterize(UnresolvedType aType, Map<String, UnresolvedType> typeVariableMap,
+                       boolean inParameterizedType, World w) {
                if (aType instanceof TypeVariableReference) {
                        String variableName = ((TypeVariableReference) aType).getTypeVariable().getName();
                        if (!typeVariableMap.containsKey(variableName)) {
                                return aType; // if the type variable comes from the method (and
                                // not the type) thats OK
                        }
-                       return (UnresolvedType) typeVariableMap.get(variableName);
+                       return typeVariableMap.get(variableName);
                } else if (aType.isParameterizedType()) {
                        if (inParameterizedType) {
                                if (w != null) {
@@ -982,7 +985,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                StringBuffer sig = new StringBuffer();
                UnresolvedType[] myParameterTypes = getGenericParameterTypes();
                for (int i = 0; i < myParameterTypes.length; i++) {
-                       appendSigWithTypeVarBoundsRemoved(myParameterTypes[i], sig, new HashSet());
+                       appendSigWithTypeVarBoundsRemoved(myParameterTypes[i], sig, new HashSet<UnresolvedType>());
                }
                myParameterSignatureWithBoundsRemoved = sig.toString();
                return myParameterSignatureWithBoundsRemoved;
@@ -1019,7 +1022,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
        // does NOT produce a meaningful java signature, but does give a unique
        // string suitable for
        // comparison.
-       public static void appendSigWithTypeVarBoundsRemoved(UnresolvedType aType, StringBuffer toBuffer, Set alreadyUsedTypeVars) {
+       public static void appendSigWithTypeVarBoundsRemoved(UnresolvedType aType, StringBuffer toBuffer,
+                       Set<UnresolvedType> alreadyUsedTypeVars) {
                if (aType.isTypeVariableReference()) {
                        TypeVariableReferenceType typeVariableRT = (TypeVariableReferenceType) aType;
                        // pr204505
index 7e4932f9646d6e7d4b8fcad47b2f961564dff29d..0f898eec4f199cba8c0fd9bc8f6c22387538c94a 100644 (file)
@@ -1012,6 +1012,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        // ---- fields
 
        public static final ResolvedType[] NONE = new ResolvedType[0];
+       public static final ResolvedType[] EMPTY_ARRAY = NONE;
 
        public static final Primitive BYTE = new Primitive("B", 1, 0);
        public static final Primitive CHAR = new Primitive("C", 1, 1);
index f982f89c3c2b5ac2939f93fbece73088aa737675..28c8aacf67f3645e018de23269e5051233748483 100644 (file)
@@ -12,7 +12,7 @@
 package org.aspectj.weaver.reflect;
 
 import java.lang.reflect.Member;
-import java.util.Iterator;
+import java.util.Set;
 
 import org.aspectj.weaver.AnnotationAJ;
 import org.aspectj.weaver.MemberKind;
@@ -22,8 +22,7 @@ import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.UnresolvedType;
 
 /**
- * Subtype of ResolvedMemberImpl used in reflection world. Knows how to get
- * annotations from a java.lang.reflect.Member
+ * Subtype of ResolvedMemberImpl used in reflection world. Knows how to get annotations from a java.lang.reflect.Member
  * 
  */
 public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
@@ -41,10 +40,8 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * @param name
         * @param parameterTypes
         */
-       public ReflectionBasedResolvedMemberImpl(MemberKind kind,
-                       UnresolvedType declaringType, int modifiers,
-                       UnresolvedType returnType, String name,
-                       UnresolvedType[] parameterTypes, Member reflectMember) {
+       public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers,
+                       UnresolvedType returnType, String name, UnresolvedType[] parameterTypes, Member reflectMember) {
                super(kind, declaringType, modifiers, returnType, name, parameterTypes);
                this.reflectMember = reflectMember;
        }
@@ -58,13 +55,10 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * @param parameterTypes
         * @param checkedExceptions
         */
-       public ReflectionBasedResolvedMemberImpl(MemberKind kind,
-                       UnresolvedType declaringType, int modifiers,
-                       UnresolvedType returnType, String name,
-                       UnresolvedType[] parameterTypes,
-                       UnresolvedType[] checkedExceptions, Member reflectMember) {
-               super(kind, declaringType, modifiers, returnType, name, parameterTypes,
-                               checkedExceptions);
+       public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers,
+                       UnresolvedType returnType, String name, UnresolvedType[] parameterTypes, UnresolvedType[] checkedExceptions,
+                       Member reflectMember) {
+               super(kind, declaringType, modifiers, returnType, name, parameterTypes, checkedExceptions);
                this.reflectMember = reflectMember;
        }
 
@@ -78,14 +72,10 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * @param checkedExceptions
         * @param backingGenericMember
         */
-       public ReflectionBasedResolvedMemberImpl(MemberKind kind,
-                       UnresolvedType declaringType, int modifiers,
-                       UnresolvedType returnType, String name,
-                       UnresolvedType[] parameterTypes,
-                       UnresolvedType[] checkedExceptions,
+       public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers,
+                       UnresolvedType returnType, String name, UnresolvedType[] parameterTypes, UnresolvedType[] checkedExceptions,
                        ResolvedMember backingGenericMember, Member reflectMember) {
-               super(kind, declaringType, modifiers, returnType, name, parameterTypes,
-                               checkedExceptions, backingGenericMember);
+               super(kind, declaringType, modifiers, returnType, name, parameterTypes, checkedExceptions, backingGenericMember);
                this.reflectMember = reflectMember;
        }
 
@@ -96,8 +86,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * @param name
         * @param signature
         */
-       public ReflectionBasedResolvedMemberImpl(MemberKind kind,
-                       UnresolvedType declaringType, int modifiers, String name,
+       public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, String name,
                        String signature, Member reflectMember) {
                super(kind, declaringType, modifiers, name, signature);
                this.reflectMember = reflectMember;
@@ -109,8 +98,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
 
        // generic signature support
 
-       public void setGenericSignatureInformationProvider(
-                       GenericSignatureInformationProvider gsigProvider) {
+       public void setGenericSignatureInformationProvider(GenericSignatureInformationProvider gsigProvider) {
                this.gsigInfoProvider = gsigProvider;
        }
 
@@ -119,6 +107,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * 
         * @see org.aspectj.weaver.ResolvedMemberImpl#getGenericParameterTypes()
         */
+       @Override
        public UnresolvedType[] getGenericParameterTypes() {
                return this.gsigInfoProvider.getGenericParameterTypes(this);
        }
@@ -128,6 +117,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * 
         * @see org.aspectj.weaver.ResolvedMemberImpl#getGenericReturnType()
         */
+       @Override
        public UnresolvedType getGenericReturnType() {
                return this.gsigInfoProvider.getGenericReturnType(this);
        }
@@ -137,6 +127,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * 
         * @see org.aspectj.weaver.ResolvedMemberImpl#isSynthetic()
         */
+       @Override
        public boolean isSynthetic() {
                return this.gsigInfoProvider.isSynthetic(this);
        }
@@ -146,6 +137,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * 
         * @see org.aspectj.weaver.ResolvedMemberImpl#isVarargsMethod()
         */
+       @Override
        public boolean isVarargsMethod() {
                return this.gsigInfoProvider.isVarArgs(this);
        }
@@ -155,6 +147,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
         * 
         * @see org.aspectj.weaver.ResolvedMemberImpl#isBridgeMethod()
         */
+       @Override
        public boolean isBridgeMethod() {
                return this.gsigInfoProvider.isBridge(this);
        }
@@ -165,52 +158,66 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
                this.annotationFinder = finder;
        }
 
+       @Override
        public boolean hasAnnotation(UnresolvedType ofType) {
                unpackAnnotations();
                return super.hasAnnotation(ofType);
        }
 
+       @Override
        public boolean hasAnnotations() {
                unpackAnnotations();
                return super.hasAnnotations();
        }
 
+       @Override
        public ResolvedType[] getAnnotationTypes() {
                unpackAnnotations();
                return super.getAnnotationTypes();
        }
 
+       @Override
        public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) {
                unpackAnnotations();
-               if (annotationFinder == null)
+               if (annotationFinder == null || annotationTypes == null) {
                        return null;
-               for (Iterator iterator = annotationTypes.iterator(); iterator.hasNext();) {
-                       ResolvedType type = (ResolvedType) iterator.next();
+               }
+               for (ResolvedType type : annotationTypes) {
                        if (type.getSignature().equals(ofType.getSignature())) {
-                               return annotationFinder.getAnnotationOfType(ofType,
-                                               reflectMember);
+                               return annotationFinder.getAnnotationOfType(ofType, reflectMember);
                        }
                }
                return null;
        }
 
+       @Override
        public String getAnnotationDefaultValue() {
-               if (annotationFinder == null)
+               if (annotationFinder == null) {
                        return null;
+               }
                return annotationFinder.getAnnotationDefaultValue(reflectMember);
        }
 
+       @Override
        public ResolvedType[][] getParameterAnnotationTypes() {
                if (parameterAnnotationTypes == null && annotationFinder != null) {
-                       parameterAnnotationTypes = annotationFinder
-                                       .getParameterAnnotationTypes(reflectMember);
+                       parameterAnnotationTypes = annotationFinder.getParameterAnnotationTypes(reflectMember);
                }
                return parameterAnnotationTypes;
        }
 
        private void unpackAnnotations() {
                if (annotationTypes == null && annotationFinder != null) {
-                       annotationTypes = annotationFinder.getAnnotations(reflectMember);
+                       Set<?> s = annotationFinder.getAnnotations(reflectMember);
+                       if (s.size() == 0) {
+                               annotationTypes = ResolvedType.EMPTY_ARRAY;
+                       } else {
+                               annotationTypes = new ResolvedType[s.size()];
+                               int i = 0;
+                               for (Object o : s) {
+                                       annotationTypes[i++] = (ResolvedType) o;
+                               }
+                       }
                }
        }
 }