]> source.dussan.org Git - aspectj.git/commitdiff
refactoring
authoraclement <aclement>
Mon, 14 Sep 2009 17:58:55 +0000 (17:58 +0000)
committeraclement <aclement>
Mon, 14 Sep 2009 17:58:55 +0000 (17:58 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/Iterators.java
org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java
org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
org.aspectj.matcher/src/org/aspectj/weaver/ReferenceTypeDelegate.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/ResolvedTypeMunger.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java
org.aspectj.matcher/testsrc/org/aspectj/weaver/CommonWorldTests.java

index 1e5e6e6f531c01f403381a6307f189bb566d5297..1afc4a56445fab5049f0a63f8b51a00d124b592d 100644 (file)
@@ -28,36 +28,38 @@ public final class Iterators {
        /**
         * A getter represents a mapping function from Object to Iterator
         */
-       public interface Getter {
-               Iterator get(Object target);
+       public interface Getter<A, B> {
+               Iterator<B> get(A target);
        }
 
        /**
         * A filter represents a mapping function from Iterator to Iterator
         */
-       public interface Filter {
-               Iterator filter(Iterator in);
+       public interface Filter<T> {
+               Iterator<T> filter(Iterator<T> in);
        }
 
        /**
         * Create a new filter F that, when wrapped around another iterator I, creates a new iterator I' that will return only those
         * values of I that have not yet been returned by I', discarding duplicates.
         */
-       public static Filter dupFilter() {
-               return new Filter() {
-                       final Set seen = new HashSet(); // should have weak ptrs?
+       public static <T> Filter<T> dupFilter() {
+               return new Filter<T>() {
+                       final Set<T> seen = new HashSet<T>(); // should have weak ptrs?
 
-                       public Iterator filter(final Iterator in) {
-                               return new Iterator() {
+                       public Iterator<T> filter(final Iterator<T> in) {
+                               return new Iterator<T>() {
                                        boolean fresh = false;
-                                       Object peek;
+                                       T peek;
 
                                        public boolean hasNext() {
-                                               if (fresh)
+                                               if (fresh) {
                                                        return true;
+                                               }
                                                while (true) {
-                                                       if (!in.hasNext())
+                                                       if (!in.hasNext()) {
                                                                return false;
+                                                       }
                                                        peek = in.next();
                                                        if (!seen.contains(peek)) {
                                                                return fresh = true;
@@ -67,10 +69,11 @@ public final class Iterators {
                                                }
                                        }
 
-                                       public Object next() {
+                                       public T next() {
                                                if (!hasNext())
                                                        throw new NoSuchElementException();
-                                               Object ret = peek;
+                                               T ret = peek;
+                                               seen.add(peek);
                                                peek = null;
                                                fresh = false;
                                                return ret;
@@ -89,8 +92,8 @@ public final class Iterators {
         * all that pesky safety.
         */
 
-       public static Iterator array(final Object[] o) {
-               return new Iterator() {
+       public static <T> Iterator<T> array(final T[] o) {
+               return new Iterator<T>() {
                        int i = 0;
                        int len = (o == null) ? 0 : o.length;
 
@@ -98,7 +101,7 @@ public final class Iterators {
                                return i < len;
                        }
 
-                       public Object next() {
+                       public T next() {
                                if (i < len) {
                                        return o[i++];
                                } else {
@@ -115,18 +118,18 @@ public final class Iterators {
        /**
         * creates an iterator I based on a base iterator A and a getter G. I returns, in order, forall (i in I), G(i).
         */
-       public static Iterator mapOver(final Iterator a, final Getter g) {
-               return new Iterator() {
-                       Iterator delegate = new Iterator() {
+       public static <A, B> Iterator<B> mapOver(final Iterator<A> a, final Getter<A, B> g) {
+               return new Iterator<B>() {
+                       Iterator<B> delegate = new Iterator<B>() {
                                public boolean hasNext() {
                                        if (!a.hasNext())
                                                return false;
-                                       Object o = a.next();
+                                       A o = a.next();
                                        delegate = append1(g.get(o), this);
                                        return delegate.hasNext();
                                }
 
-                               public Object next() {
+                               public B next() {
                                        if (!hasNext())
                                                throw new UnsupportedOperationException();
                                        return delegate.next();
@@ -141,7 +144,7 @@ public final class Iterators {
                                return delegate.hasNext();
                        }
 
-                       public Object next() {
+                       public B next() {
                                return delegate.next();
                        }
 
@@ -155,16 +158,16 @@ public final class Iterators {
         * creates an iterator I based on a base iterator A and a getter G. I returns, in order, forall (i in I) i :: forall (i' in
         * g(i)) recur(i', g)
         */
-       public static Iterator recur(final Object a, final Getter g) {
-               return new Iterator() {
-                       Iterator delegate = one(a);
+       public static <A> Iterator<A> recur(final A a, final Getter<A, A> g) {
+               return new Iterator<A>() {
+                       Iterator<A> delegate = one(a);
 
                        public boolean hasNext() {
                                return delegate.hasNext();
                        }
 
-                       public Object next() {
-                               Object next = delegate.next();
+                       public A next() {
+                               A next = delegate.next();
                                delegate = append(g.get(next), delegate);
                                return next;
                        }
@@ -179,7 +182,7 @@ public final class Iterators {
         * creates an iterator I based on base iterators A and B. Returns the elements returned by A followed by those returned by B. If
         * B is empty, simply returns A, and if A is empty, simply returns B. Do NOT USE if b.hasNext() is not idempotent.
         */
-       public static Iterator append(final Iterator a, final Iterator b) {
+       public static <T> Iterator<T> append(final Iterator<T> a, final Iterator<T> b) {
                if (!b.hasNext())
                        return a;
                return append1(a, b);
@@ -189,15 +192,15 @@ public final class Iterators {
         * creates an iterator I based on base iterators A and B. Returns the elements returned by A followed by those returned by B. If
         * A is empty, simply returns B. Guaranteed not to call B.hasNext() until A is empty.
         */
-       public static Iterator append1(final Iterator a, final Iterator b) {
+       public static <T> Iterator<T> append1(final Iterator<T> a, final Iterator<T> b) {
                if (!a.hasNext())
                        return b;
-               return new Iterator() {
+               return new Iterator<T>() {
                        public boolean hasNext() {
                                return a.hasNext() || b.hasNext();
                        }
 
-                       public Object next() {
+                       public T next() {
                                if (a.hasNext())
                                        return a.next();
                                if (b.hasNext())
@@ -214,20 +217,20 @@ public final class Iterators {
        /**
         * creates an iterator I based on a base iterator A and an object O. Returns the elements returned by A, followed by O.
         */
-       public static Iterator snoc(final Iterator first, final Object last) {
-               return new Iterator() {
-                       Object last1 = last;
+       public static <T> Iterator<T> snoc(final Iterator<T> first, final T last) {
+               return new Iterator<T>() {
+                       T last1 = last;
 
                        public boolean hasNext() {
                                return first.hasNext() || last1 != null;
                        }
 
-                       public Object next() {
+                       public T next() {
                                if (first.hasNext())
                                        return first.next();
                                else if (last1 == null)
                                        throw new NoSuchElementException();
-                               Object ret = last1;
+                               T ret = last1;
                                last1 = null;
                                return ret;
                        }
@@ -241,17 +244,18 @@ public final class Iterators {
        /**
         * creates an iterator I based on an object O. Returns O, once.
         */
-       public static Iterator one(final Object it) {
-               return new Iterator() {
+       public static <T> Iterator<T> one(final T it) {
+               return new Iterator<T>() {
                        boolean avail = true;
 
                        public boolean hasNext() {
                                return avail;
                        }
 
-                       public Object next() {
-                               if (!avail)
+                       public T next() {
+                               if (!avail) {
                                        throw new NoSuchElementException();
+                               }
                                avail = false;
                                return it;
                        }
index 8cc690e77889aacbd9471750771fb6060ce7e33d..19cc2d5cdd3241c6a1ce869d3a1a72772cff33b9 100644 (file)
@@ -91,7 +91,7 @@ public class JoinPointSignature implements ResolvedMember {
                return realMember.getAnnotationOfType(ofType);
        }
 
-       public void setAnnotationTypes(UnresolvedType[] annotationtypes) {
+       public void setAnnotationTypes(ResolvedType[] annotationtypes) {
                realMember.setAnnotationTypes(annotationtypes);
        }
 
@@ -309,6 +309,7 @@ public class JoinPointSignature implements ResolvedMember {
                return realMember.getJoinPointSignatures(world);
        }
 
+       @Override
        public String toString() {
                StringBuffer buf = new StringBuffer();
                buf.append(getReturnType().getName());
@@ -355,6 +356,7 @@ public class JoinPointSignature implements ResolvedMember {
                realMember.resetReturnTypeToObjectArray();
        }
 
+       @Override
        public boolean equals(Object obj) {
                if (!(obj instanceof JoinPointSignature))
                        return false;
@@ -366,6 +368,7 @@ public class JoinPointSignature implements ResolvedMember {
                return true;
        }
 
+       @Override
        public int hashCode() {
                return 17 + (37 * realMember.hashCode()) + (37 * substituteDeclaringType.hashCode());
        }
index 4da37be9ed267bfa907485fa05ffd021c5f9cc98..5f72c11541871b123b47bdafb8dff7910b4f1e28 100644 (file)
@@ -113,6 +113,7 @@ public class ReferenceType extends ResolvedType {
                this.derivativeTypes.add(dependent);
        }
 
+       @Override
        public String getSignatureForAttribute() {
                if (genericType == null || typeParameters == null)
                        return getSignature();
@@ -127,10 +128,12 @@ public class ReferenceType extends ResolvedType {
                typeKind = TypeKind.GENERIC;
        }
 
+       @Override
        public boolean isClass() {
                return delegate.isClass();
        }
 
+       @Override
        public boolean isGenericType() {
                return !isParameterizedType() && !isRawType() && delegate.isGeneric();
        }
@@ -140,10 +143,12 @@ public class ReferenceType extends ResolvedType {
                return (sig == null) ? "" : sig;
        }
 
+       @Override
        public AnnotationAJ[] getAnnotations() {
                return delegate.getAnnotations();
        }
 
+       @Override
        public void addAnnotation(AnnotationAJ annotationX) {
                if (annotations == null) {
                        annotations = new AnnotationAJ[1];
@@ -184,6 +189,7 @@ public class ReferenceType extends ResolvedType {
                }
        }
 
+       @Override
        public ResolvedType[] getAnnotationTypes() {
                if (delegate == null) {
                        throw new BCException("Unexpected null delegate for type " + this.getName());
@@ -200,6 +206,7 @@ public class ReferenceType extends ResolvedType {
                }
        }
 
+       @Override
        public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) {
                AnnotationAJ[] axs = delegate.getAnnotations();
                if (axs == null) {
@@ -221,26 +228,32 @@ public class ReferenceType extends ResolvedType {
                return null;
        }
 
+       @Override
        public boolean isAspect() {
                return delegate.isAspect();
        }
 
+       @Override
        public boolean isAnnotationStyleAspect() {
                return delegate.isAnnotationStyleAspect();
        }
 
+       @Override
        public boolean isEnum() {
                return delegate.isEnum();
        }
 
+       @Override
        public boolean isAnnotation() {
                return delegate.isAnnotation();
        }
 
+       @Override
        public boolean isAnonymous() {
                return delegate.isAnonymous();
        }
 
+       @Override
        public boolean isNested() {
                return delegate.isNested();
        }
@@ -253,19 +266,23 @@ public class ReferenceType extends ResolvedType {
                return delegate.getRetentionPolicy();
        }
 
+       @Override
        public boolean isAnnotationWithRuntimeRetention() {
                return delegate.isAnnotationWithRuntimeRetention();
        }
 
+       @Override
        public boolean canAnnotationTargetType() {
                return delegate.canAnnotationTargetType();
        }
 
+       @Override
        public AnnotationTargetKind[] getAnnotationTargetKinds() {
                return delegate.getAnnotationTargetKinds();
        }
 
        // true iff the statement "this = (ThisType) other" would compile
+       @Override
        public boolean isCoerceableFrom(ResolvedType o) {
                ResolvedType other = o.resolve(world);
 
@@ -359,6 +376,7 @@ public class ReferenceType extends ResolvedType {
                return false;
        }
 
+       @Override
        public boolean isAssignableFrom(ResolvedType other) {
                return isAssignableFrom(other, false);
        }
@@ -366,6 +384,7 @@ public class ReferenceType extends ResolvedType {
        // TODO rewrite this method - it is a terrible mess
 
        // true iff the statement "this = other" would compile.
+       @Override
        public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) {
                if (other.isPrimitiveType()) {
                        if (!world.isInJava5Mode())
@@ -524,25 +543,30 @@ public class ReferenceType extends ResolvedType {
                return false;
        }
 
+       @Override
        public ISourceContext getSourceContext() {
                return delegate.getSourceContext();
        }
 
+       @Override
        public ISourceLocation getSourceLocation() {
                ISourceContext isc = delegate.getSourceContext();
                return isc.makeSourceLocation(new Position(startPos, endPos));
        }
 
+       @Override
        public boolean isExposedToWeaver() {
                return (delegate == null) || delegate.isExposedToWeaver(); // ??? where
                // does this
                // belong
        }
 
+       @Override
        public WeaverStateInfo getWeaverState() {
                return delegate.getWeaverState();
        }
 
+       @Override
        public ResolvedMember[] getDeclaredFields() {
                if (parameterizedFields != null)
                        return parameterizedFields;
@@ -563,6 +587,7 @@ public class ReferenceType extends ResolvedType {
         * Find out from the generic signature the true signature of any interfaces I implement. If I am parameterized, these may then
         * need to be parameterized before returning.
         */
+       @Override
        public ResolvedType[] getDeclaredInterfaces() {
                if (parameterizedInterfaces != null)
                        return parameterizedInterfaces;
@@ -682,6 +707,7 @@ public class ReferenceType extends ResolvedType {
                return -1;
        }
 
+       @Override
        public ResolvedMember[] getDeclaredMethods() {
                if (parameterizedMethods != null)
                        return parameterizedMethods;
@@ -698,6 +724,7 @@ public class ReferenceType extends ResolvedType {
                }
        }
 
+       @Override
        public ResolvedMember[] getDeclaredPointcuts() {
                if (parameterizedPointcuts != null)
                        return parameterizedPointcuts;
@@ -729,10 +756,12 @@ public class ReferenceType extends ResolvedType {
                return parameters;
        }
 
+       @Override
        public UnresolvedType getRawType() {
                return super.getRawType().resolve(world);
        }
 
+       @Override
        public TypeVariable[] getTypeVariables() {
                if (this.typeVariables == null) {
                        this.typeVariables = delegate.getTypeVariables();
@@ -743,6 +772,7 @@ public class ReferenceType extends ResolvedType {
                return this.typeVariables;
        }
 
+       @Override
        public PerClause getPerClause() {
                PerClause pclause = delegate.getPerClause();
                if (isParameterizedType()) { // could cache the result here...
@@ -752,10 +782,11 @@ public class ReferenceType extends ResolvedType {
                return pclause;
        }
 
-       public Collection getDeclares() {
+       @Override
+       public Collection<Declare> getDeclares() {
                if (parameterizedDeclares != null)
                        return parameterizedDeclares;
-               Collection declares = null;
+               Collection<Declare> declares = null;
                if (ajMembersNeedParameterization()) {
                        Collection genericDeclares = delegate.getDeclares();
                        parameterizedDeclares = new ArrayList();
@@ -768,13 +799,13 @@ public class ReferenceType extends ResolvedType {
                } else {
                        declares = delegate.getDeclares();
                }
-               for (Iterator iter = declares.iterator(); iter.hasNext();) {
-                       Declare d = (Declare) iter.next();
+               for (Declare d : declares) {
                        d.setDeclaringType(this);
                }
                return declares;
        }
 
+       @Override
        public Collection getTypeMungers() {
                return delegate.getTypeMungers();
        }
@@ -800,14 +831,17 @@ public class ReferenceType extends ResolvedType {
        // return ret;
        // }
 
+       @Override
        public Collection getPrivilegedAccesses() {
                return delegate.getPrivilegedAccesses();
        }
 
+       @Override
        public int getModifiers() {
                return delegate.getModifiers();
        }
 
+       @Override
        public ResolvedType getSuperclass() {
                if (newSuperclass != null) {
                        if (this.isParameterizedType() && newSuperclass.isParameterizedType()) {
@@ -879,6 +913,7 @@ public class ReferenceType extends ResolvedType {
                this.startPos = startPos;
        }
 
+       @Override
        public boolean doesNotExposeShadowMungers() {
                return delegate.doesNotExposeShadowMungers();
        }
@@ -903,6 +938,7 @@ public class ReferenceType extends ResolvedType {
                signatureErasure = null;
        }
 
+       @Override
        public ResolvedType getGenericType() {
                if (isGenericType())
                        return this;
@@ -941,6 +977,7 @@ public class ReferenceType extends ResolvedType {
                return ret.toString();
        }
 
+       @Override
        public void ensureConsistent() {
                annotations = null;
                annotationTypes = null;
@@ -948,6 +985,7 @@ public class ReferenceType extends ResolvedType {
                newInterfaces = null;
        }
 
+       @Override
        public void addParent(ResolvedType newParent) {
                if (newParent.isClass()) {
                        newSuperclass = newParent;
index 014e40b8328db356c2c42627e819797046c65b43..850a79d8d4c4ce7f90b3ce72f869f65b27238fbe 100644 (file)
@@ -14,6 +14,7 @@ package org.aspectj.weaver;
 
 import java.util.Collection;
 
+import org.aspectj.weaver.patterns.Declare;
 import org.aspectj.weaver.patterns.PerClause;
 
 /**
@@ -24,7 +25,7 @@ import org.aspectj.weaver.patterns.PerClause;
 public interface ReferenceTypeDelegate {
 
        public boolean isAspect();
-       
+
        /**
         * @return true if the type is an annotation style aspect (a type marked @Aspect)
         */
@@ -85,7 +86,7 @@ public interface ReferenceTypeDelegate {
         */
        public PerClause getPerClause();
 
-       public Collection getDeclares();
+       public Collection<Declare> getDeclares();
 
        public Collection getTypeMungers();
 
index 84679cce022d56eab1e5c106d27d3e80459ed9c0..93d698415f313fcae3ffc7cf7bcf5c8910628a83 100644 (file)
@@ -46,7 +46,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
 
        public ResolvedType[] getAnnotationTypes();
 
-       public void setAnnotationTypes(UnresolvedType[] annotationtypes);
+       public void setAnnotationTypes(ResolvedType[] annotationtypes);
 
        public void addAnnotation(AnnotationAJ annotation);
 
index 9a3c2bf5e5e429a57b592a34ca01a88423a0b528..44522858f9981fb82d4a31a50b10b039b7b1b47b 100644 (file)
@@ -39,7 +39,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
         */
        protected ResolvedMember backingGenericMember = null;
 
-       protected Set<UnresolvedType> annotationTypes = null;
+       protected Set<ResolvedType> annotationTypes = null;
        protected ResolvedType[][] parameterAnnotationTypes = null;
 
        // Some members are 'created' to represent other things (for example ITDs).
@@ -123,11 +123,10 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                        // }
                }
 
-               List declaringTypes = new ArrayList();
+               List<ResolvedType> declaringTypes = new ArrayList<ResolvedType>();
                accumulateTypesInBetween(originalDeclaringType, firstDefiningType, declaringTypes);
-               Set memberSignatures = new HashSet();
-               for (Iterator iter = declaringTypes.iterator(); iter.hasNext();) {
-                       ResolvedType declaringType = (ResolvedType) iter.next();
+               Set<ResolvedMember> memberSignatures = new HashSet<ResolvedMember>();
+               for (ResolvedType declaringType : declaringTypes) {
                        ResolvedMember member = firstDefiningMember.withSubstituteDeclaringType(declaringType);
                        memberSignatures.add(member);
                }
@@ -137,7 +136,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                        // include the signature for
                        // every type between the firstDefiningMember and the root defining
                        // member.
-                       Iterator superTypeIterator = firstDefiningType.getDirectSupertypes();
+                       Iterator<ResolvedType> superTypeIterator = firstDefiningType.getDirectSupertypes();
                        List typesAlreadyVisited = new ArrayList();
                        accumulateMembersMatching(firstDefiningMember, superTypeIterator, typesAlreadyVisited, memberSignatures, false);
                }
@@ -160,13 +159,13 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
        /**
         * Build a list containing every type between subtype and supertype, inclusively.
         */
-       private static void accumulateTypesInBetween(ResolvedType subType, ResolvedType superType, List types) {
+       private static void accumulateTypesInBetween(ResolvedType subType, ResolvedType superType, List<ResolvedType> types) {
                types.add(subType);
                if (subType == superType) {
                        return;
                } else {
-                       for (Iterator iter = subType.getDirectSupertypes(); iter.hasNext();) {
-                               ResolvedType parent = (ResolvedType) iter.next();
+                       for (Iterator<ResolvedType> iter = subType.getDirectSupertypes(); iter.hasNext();) {
+                               ResolvedType parent = iter.next();
                                if (superType.isAssignableFrom(parent)) {
                                        accumulateTypesInBetween(parent, superType, types);
                                }
@@ -178,22 +177,21 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
         * We have a resolved member, possibly with type parameter references as parameters or return type. We need to find all its
         * ancestor members. When doing this, a type parameter matches regardless of bounds (bounds can be narrowed down the hierarchy).
         */
-       private static void accumulateMembersMatching(ResolvedMemberImpl memberToMatch, Iterator typesToLookIn,
-                       List typesAlreadyVisited, Set foundMembers, boolean ignoreGenerics) {
+       private static void accumulateMembersMatching(ResolvedMemberImpl memberToMatch, Iterator<ResolvedType> typesToLookIn,
+                       List<ResolvedType> typesAlreadyVisited, Set<ResolvedMember> foundMembers, boolean ignoreGenerics) {
                while (typesToLookIn.hasNext()) {
-                       ResolvedType toLookIn = (ResolvedType) typesToLookIn.next();
+                       ResolvedType toLookIn = typesToLookIn.next();
                        if (!typesAlreadyVisited.contains(toLookIn)) {
                                typesAlreadyVisited.add(toLookIn);
                                ResolvedMemberImpl foundMember = (ResolvedMemberImpl) toLookIn.lookupResolvedMember(memberToMatch, true,
                                                ignoreGenerics);
                                if (foundMember != null && isVisibleTo(memberToMatch, foundMember)) {
-                                       List declaringTypes = new ArrayList();
+                                       List<ResolvedType> declaringTypes = new ArrayList<ResolvedType>();
                                        // declaring type can be unresolved if the member can from
                                        // an ITD...
                                        ResolvedType resolvedDeclaringType = foundMember.getDeclaringType().resolve(toLookIn.getWorld());
                                        accumulateTypesInBetween(toLookIn, resolvedDeclaringType, declaringTypes);
-                                       for (Iterator iter = declaringTypes.iterator(); iter.hasNext();) {
-                                               ResolvedType declaringType = (ResolvedType) iter.next();
+                                       for (ResolvedType declaringType : declaringTypes) {
                                                // typesAlreadyVisited.add(declaringType);
                                                ResolvedMember member = foundMember.withSubstituteDeclaringType(declaringType);
                                                foundMembers.add(member);
@@ -323,12 +321,12 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                return super.getAnnotations();
        }
 
-       public void setAnnotationTypes(UnresolvedType[] annotationtypes) {
+       public void setAnnotationTypes(ResolvedType[] annotationtypes) {
                if (annotationTypes == null) {
-                       annotationTypes = new HashSet<UnresolvedType>();
+                       annotationTypes = new HashSet<ResolvedType>();
                }
                for (int i = 0; i < annotationtypes.length; i++) {
-                       UnresolvedType typeX = annotationtypes[i];
+                       ResolvedType typeX = annotationtypes[i];
                        annotationTypes.add(typeX);
                }
        }
@@ -350,7 +348,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                // FIXME asc only allows for annotation types, not instances - should
                // it?
                if (annotationTypes == null) {
-                       annotationTypes = new HashSet<UnresolvedType>();
+                       annotationTypes = new HashSet<ResolvedType>();
                }
                annotationTypes.add(annotation.getType());
        }
@@ -526,15 +524,15 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                                }
                        }
                        world.setTypeVariableLookupScope(this);
-                       if (annotationTypes != null) {
-                               Set<UnresolvedType> r = new HashSet<UnresolvedType>();
-                               for (UnresolvedType element : annotationTypes) {
-                                       // for (Iterator iter = annotationTypes.iterator(); iter.hasNext();) {
-                                       // UnresolvedType element = (UnresolvedType) iter.next();
-                                       r.add(world.resolve(element));
-                               }
-                               annotationTypes = r;
-                       }
+                       // if (annotationTypes != null) {
+                       // Set<ResolvedType> r = new HashSet<ResolvedType>();
+                       // for (UnresolvedType element : annotationTypes) {
+                       // // for (Iterator iter = annotationTypes.iterator(); iter.hasNext();) {
+                       // // UnresolvedType element = (UnresolvedType) iter.next();
+                       // r.add(world.resolve(element));
+                       // }
+                       // annotationTypes = r;
+                       // }
                        declaringType = declaringType.resolve(world);
                        if (declaringType.isRawType())
                                declaringType = ((ReferenceType) declaringType).getGenericType();
@@ -682,7 +680,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                if (isParameterized && (typeVariables.length != typeParameters.length)) {
                        throw new IllegalStateException("Wrong number of type parameters supplied");
                }
-               Map typeMap = new HashMap();
+               Map<String, UnresolvedType> typeMap = new HashMap<String, UnresolvedType>();
                boolean typeParametersSupplied = typeParameters != null && typeParameters.length > 0;
                if (typeVariables != null) {
                        // If no 'replacements' were supplied in the typeParameters array
index 2c0b52d2c8a0bc1c5249c2848314a3b890c7b05a..5095c0f0eaf21a8f1cc33e1a6739c3bd53c8a8be 100644 (file)
@@ -62,8 +62,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
         * Returns an iterator through ResolvedType objects representing all the direct supertypes of this type. That is, through the
         * superclass, if any, and all declared interfaces.
         */
-       public final Iterator getDirectSupertypes() {
-               Iterator ifacesIterator = Iterators.array(getDeclaredInterfaces());
+       public final Iterator<ResolvedType> getDirectSupertypes() {
+               Iterator<ResolvedType> ifacesIterator = Iterators.array(getDeclaredInterfaces());
                ResolvedType superclass = getSuperclass();
                if (superclass == null) {
                        return ifacesIterator;
@@ -85,20 +85,10 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        }
 
        /**
-        * Returns a ResolvedType object representing the superclass of this type, or null. If this represents a java.lang.Object, a
-        * primitive type, or void, this method returns null.
+        * @return the superclass of this type, or null (if this represents a jlObject, primitive, or void)
         */
        public abstract ResolvedType getSuperclass();
 
-       /**
-        * Returns the modifiers for this type.
-        * <p/>
-        * See {@link Class#getModifiers()} for a description of the weirdness of this methods on primitives and arrays.
-        * 
-        * @param world the {@link World} in which the lookup is made.
-        * @return an int representing the modifiers for this type
-        * @see java.lang.reflect.Modifier
-        */
        public abstract int getModifiers();
 
        // return true if this resolved type couldn't be found (but we know it's
@@ -133,7 +123,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        // This set contains pairs of types whose signatures are concatenated
        // together, this means with a fast lookup we can tell if two types
        // are equivalent.
-       protected static Set validBoxing = new HashSet();
+       protected static Set<String> validBoxing = new HashSet<String>();
 
        static {
                validBoxing.add("Ljava/lang/Byte;B");
@@ -188,16 +178,16 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
         * <p/>
         * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land.
         */
-       public Iterator getFields() {
-               final Iterators.Filter dupFilter = Iterators.dupFilter();
-               Iterators.Getter typeGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
-                               return dupFilter.filter(((ResolvedType) o).getDirectSupertypes());
+       public Iterator<ResolvedMember> getFields() {
+               final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter();
+               Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() {
+                       public Iterator<ResolvedType> get(ResolvedType o) {
+                               return dupFilter.filter((o).getDirectSupertypes());
                        }
                };
-               Iterators.Getter fieldGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
-                               return Iterators.array(((ResolvedType) o).getDeclaredFields());
+               Iterators.Getter<ResolvedType, ResolvedMember> fieldGetter = new Iterators.Getter<ResolvedType, ResolvedMember>() {
+                       public Iterator<ResolvedMember> get(ResolvedType o) {
+                               return Iterators.array((o).getDeclaredFields());
                        }
                };
                return Iterators.mapOver(Iterators.recur(this, typeGetter), fieldGetter);
@@ -216,26 +206,26 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
         * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land. NOTE: Take a look at the javadoc on
         * getMethodsWithoutIterator() to see if you are sensitive to a quirk in getMethods()
         */
-       public Iterator getMethods() {
-               final Iterators.Filter dupFilter = Iterators.dupFilter();
-               Iterators.Getter ifaceGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
-                               return dupFilter.filter(Iterators.array(((ResolvedType) o).getDeclaredInterfaces()));
+       public Iterator<ResolvedMember> getMethods() {
+               final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter();
+               Iterators.Getter<ResolvedType, ResolvedType> ifaceGetter = new Iterators.Getter<ResolvedType, ResolvedType>() {
+                       public Iterator<ResolvedType> get(ResolvedType o) {
+                               return dupFilter.filter(Iterators.array(o.getDeclaredInterfaces()));
                        }
                };
-               Iterators.Getter methodGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
-                               return Iterators.array(((ResolvedType) o).getDeclaredMethods());
+               Iterators.Getter<ResolvedType, ResolvedMember> methodGetter = new Iterators.Getter<ResolvedType, ResolvedMember>() {
+                       public Iterator<ResolvedMember> get(ResolvedType o) {
+                               return Iterators.array((o).getDeclaredMethods());
                        }
                };
-               return Iterators.mapOver(Iterators.append(new Iterator() {
+               return Iterators.mapOver(Iterators.append(new Iterator<ResolvedType>() {
                        ResolvedType curr = ResolvedType.this;
 
                        public boolean hasNext() {
                                return curr != null;
                        }
 
-                       public Object next() {
+                       public ResolvedType next() {
                                ResolvedType ret = curr;
                                curr = curr.getSuperclass();
                                return ret;
@@ -253,31 +243,30 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
         * return methods declared on *this* class twice, once at the start and once at the end - I couldn't debug that problem, so
         * created this alternative.
         */
-       public List getMethodsWithoutIterator(boolean includeITDs, boolean allowMissing) {
-               List methods = new ArrayList();
-               Set knowninterfaces = new HashSet();
+       public List<ResolvedMember> getMethodsWithoutIterator(boolean includeITDs, boolean allowMissing) {
+               List<ResolvedMember> methods = new ArrayList<ResolvedMember>();
+               Set<ResolvedType> knowninterfaces = new HashSet<ResolvedType>();
                addAndRecurse(knowninterfaces, methods, this, includeITDs, allowMissing, false);
                return methods;
        }
 
-       public List getMethodsWithoutIterator(boolean includeITDs, boolean allowMissing, boolean genericsAware) {
-               List methods = new ArrayList();
-               Set knowninterfaces = new HashSet();
+       public List<ResolvedMember> getMethodsWithoutIterator(boolean includeITDs, boolean allowMissing, boolean genericsAware) {
+               List<ResolvedMember> methods = new ArrayList<ResolvedMember>();
+               Set<ResolvedType> knowninterfaces = new HashSet<ResolvedType>();
                addAndRecurse(knowninterfaces, methods, this, includeITDs, allowMissing, genericsAware);
                return methods;
        }
 
-       private void addAndRecurse(Set knowninterfaces, List collector, ResolvedType resolvedType, boolean includeITDs,
-                       boolean allowMissing, boolean genericsAware) {
+       private void addAndRecurse(Set<ResolvedType> knowninterfaces, List<ResolvedMember> collector, ResolvedType resolvedType,
+                       boolean includeITDs, boolean allowMissing, boolean genericsAware) {
                // Add the methods declared on this type
                collector.addAll(Arrays.asList(resolvedType.getDeclaredMethods()));
                // now add all the inter-typed members too
                if (includeITDs && resolvedType.interTypeMungers != null) {
-                       for (Iterator i = interTypeMungers.iterator(); i.hasNext();) {
-                               ConcreteTypeMunger tm = (ConcreteTypeMunger) i.next();
-                               ResolvedMember rm = tm.getSignature();
+                       for (ConcreteTypeMunger typeTransformer : interTypeMungers) {
+                               ResolvedMember rm = typeTransformer.getSignature();
                                if (rm != null) { // new parent type munger can have null signature
-                                       collector.add(tm.getSignature());
+                                       collector.add(typeTransformer.getSignature());
                                }
                        }
                }
@@ -335,8 +324,21 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        /**
         * described in JVM spec 2ed 5.4.3.2
         */
-       public ResolvedMember lookupField(Member m) {
-               return lookupMember(m, getFields());
+       public ResolvedMember lookupField(Member field) {
+               Iterator<ResolvedMember> i = getFields();
+               while (i.hasNext()) {
+                       ResolvedMember resolvedMember = i.next();
+                       if (matches(resolvedMember, field)) {
+                               return resolvedMember;
+                       }
+                       if (resolvedMember.hasBackingGenericMember() && field.getName().equals(resolvedMember.getName())) {
+                               // might be worth checking the member behind the parameterized member (see pr137496)
+                               if (matches(resolvedMember.getBackingGenericMember(), field)) {
+                                       return resolvedMember;
+                               }
+                       }
+               }
+               return null;
        }
 
        /**
@@ -399,31 +401,6 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return null;
        }
 
-       /**
-        * return null if not found
-        */
-       private ResolvedMember lookupMember(Member m, Iterator i) {
-               while (i.hasNext()) {
-                       ResolvedMember f = (ResolvedMember) i.next();
-                       if (matches(f, m))
-                               return f;
-                       if (f.hasBackingGenericMember() && m.getName().equals(f.getName())) { // might
-                               // be
-                               // worth
-                               // checking
-                               // the
-                               // method
-                               // behind
-                               // the
-                               // parameterized method (see pr137496)
-                               if (matches(f.getBackingGenericMember(), m))
-                                       return f;
-                       }
-               }
-               return null; // ResolvedMember.Missing;
-               // throw new BCException("can't find " + m);
-       }
-
        /**
         * return null if not found
         */
@@ -452,7 +429,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                        toSearch = getFields();
                }
                while (toSearch.hasNext()) {
-                       ResolvedMember candidate = (ResolvedMemberImpl) toSearch.next();
+                       ResolvedMember candidate = (ResolvedMember) toSearch.next();
                        if (ignoreGenerics) {
                                if (candidate.hasBackingGenericMember()) {
                                        candidate = candidate.getBackingGenericMember();
@@ -540,18 +517,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
         * <p/>
         * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land.
         */
-       public Iterator getPointcuts() {
-               final Iterators.Filter dupFilter = Iterators.dupFilter();
+       public Iterator<ResolvedMember> getPointcuts() {
+               final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter();
                // same order as fields
-               Iterators.Getter typeGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
-                               return dupFilter.filter(((ResolvedType) o).getDirectSupertypes());
+               Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() {
+                       public Iterator<ResolvedType> get(ResolvedType o) {
+                               return dupFilter.filter(o.getDirectSupertypes());
                        }
                };
-               Iterators.Getter pointcutGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
+               Iterators.Getter<ResolvedType, ResolvedMember> pointcutGetter = new Iterators.Getter<ResolvedType, ResolvedMember>() {
+                       public Iterator<ResolvedMember> get(ResolvedType o) {
                                // System.err.println("getting for " + o);
-                               return Iterators.array(((ResolvedType) o).getDeclaredPointcuts());
+                               return Iterators.array(o.getDeclaredPointcuts());
                        }
                };
                return Iterators.mapOver(Iterators.recur(this, typeGetter), pointcutGetter);
@@ -601,12 +578,12 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return crosscuttingMembers;
        }
 
-       public final Collection collectDeclares(boolean includeAdviceLike) {
+       public final List<Declare> collectDeclares(boolean includeAdviceLike) {
                if (!this.isAspect()) {
-                       return Collections.EMPTY_LIST;
+                       return Collections.emptyList();
                }
 
-               ArrayList ret = new ArrayList();
+               List<Declare> ret = new ArrayList<Declare>();
                // if (this.isAbstract()) {
                // for (Iterator i = getDeclares().iterator(); i.hasNext();) {
                // Declare dec = (Declare) i.next();
@@ -617,16 +594,16 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
 
                if (!this.isAbstract()) {
                        // ret.addAll(getDeclares());
-                       final Iterators.Filter dupFilter = Iterators.dupFilter();
-                       Iterators.Getter typeGetter = new Iterators.Getter() {
-                               public Iterator get(Object o) {
-                                       return dupFilter.filter(((ResolvedType) o).getDirectSupertypes());
+                       final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter();
+                       Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() {
+                               public Iterator<ResolvedType> get(ResolvedType o) {
+                                       return dupFilter.filter((o).getDirectSupertypes());
                                }
                        };
-                       Iterator typeIterator = Iterators.recur(this, typeGetter);
+                       Iterator<ResolvedType> typeIterator = Iterators.recur(this, typeGetter);
 
                        while (typeIterator.hasNext()) {
-                               ResolvedType ty = (ResolvedType) typeIterator.next();
+                               ResolvedType ty = typeIterator.next();
                                // System.out.println("super: " + ty + ", " + );
                                for (Iterator i = ty.getDeclares().iterator(); i.hasNext();) {
                                        Declare dec = (Declare) i.next();
@@ -643,21 +620,22 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return ret;
        }
 
-       private final Collection collectShadowMungers() {
-               if (!this.isAspect() || this.isAbstract() || this.doesNotExposeShadowMungers())
-                       return Collections.EMPTY_LIST;
+       private final List<ShadowMunger> collectShadowMungers() {
+               if (!this.isAspect() || this.isAbstract() || this.doesNotExposeShadowMungers()) {
+                       return Collections.emptyList();
+               }
 
-               ArrayList acc = new ArrayList();
-               final Iterators.Filter dupFilter = Iterators.dupFilter();
-               Iterators.Getter typeGetter = new Iterators.Getter() {
-                       public Iterator get(Object o) {
-                               return dupFilter.filter(((ResolvedType) o).getDirectSupertypes());
+               List<ShadowMunger> acc = new ArrayList<ShadowMunger>();
+               final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter();
+               Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() {
+                       public Iterator<ResolvedType> get(ResolvedType o) {
+                               return dupFilter.filter((o).getDirectSupertypes());
                        }
                };
-               Iterator typeIterator = Iterators.recur(this, typeGetter);
+               Iterator<ResolvedType> typeIterator = Iterators.recur(this, typeGetter);
 
                while (typeIterator.hasNext()) {
-                       ResolvedType ty = (ResolvedType) typeIterator.next();
+                       ResolvedType ty = typeIterator.next();
                        acc.addAll(ty.getDeclaredShadowMungers());
                }
 
@@ -769,22 +747,24 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return Modifier.isFinal(getModifiers());
        }
 
-       protected Map /* Type variable name -> UnresolvedType */getMemberParameterizationMap() {
-               if (!isParameterizedType())
-                       return Collections.EMPTY_MAP;
+       protected Map<String, UnresolvedType> getMemberParameterizationMap() {
+               if (!isParameterizedType()) {
+                       return Collections.emptyMap();
+               }
                TypeVariable[] tvs = getGenericType().getTypeVariables();
-               Map parameterizationMap = new HashMap();
+               Map<String, UnresolvedType> parameterizationMap = new HashMap<String, UnresolvedType>();
                for (int i = 0; i < tvs.length; i++) {
                        parameterizationMap.put(tvs[i].getName(), typeParameters[i]);
                }
                return parameterizationMap;
        }
 
-       public Collection getDeclaredAdvice() {
-               List l = new ArrayList();
+       public List<ShadowMunger> getDeclaredAdvice() {
+               List<ShadowMunger> l = new ArrayList<ShadowMunger>();
                ResolvedMember[] methods = getDeclaredMethods();
-               if (isParameterizedType())
+               if (isParameterizedType()) {
                        methods = getGenericType().getDeclaredMethods();
+               }
                Map typeVariableMap = getAjMemberParameterizationMap();
                for (int i = 0, len = methods.length; i < len; i++) {
                        ShadowMunger munger = methods[i].getAssociatedShadowMunger();
@@ -820,9 +800,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return l;
        }
 
-       public Collection getDeclaredShadowMungers() {
-               Collection c = getDeclaredAdvice();
-               return c;
+       public List<ShadowMunger> getDeclaredShadowMungers() {
+               return getDeclaredAdvice();
        }
 
        // ---- only for testing!
@@ -835,11 +814,6 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return filterInJavaVisible(getDeclaredMethods());
        }
 
-       public ShadowMunger[] getDeclaredShadowMungersArray() {
-               List l = (List) getDeclaredShadowMungers();
-               return (ShadowMunger[]) l.toArray(new ShadowMunger[l.size()]);
-       }
-
        private ResolvedMember[] filterInJavaVisible(ResolvedMember[] ms) {
                List l = new ArrayList();
                for (int i = 0, len = ms.length; i < len; i++) {
@@ -1187,12 +1161,12 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                return interTypeMungers;
        }
 
-       public List getInterTypeParentMungers() {
-               List l = new ArrayList();
-               for (Iterator iter = interTypeMungers.iterator(); iter.hasNext();) {
-                       ConcreteTypeMunger element = (ConcreteTypeMunger) iter.next();
-                       if (element.getMunger() instanceof NewParentTypeMunger)
+       public List<ConcreteTypeMunger> getInterTypeParentMungers() {
+               List<ConcreteTypeMunger> l = new ArrayList<ConcreteTypeMunger>();
+               for (ConcreteTypeMunger element : interTypeMungers) {
+                       if (element.getMunger() instanceof NewParentTypeMunger) {
                                l.add(element);
+                       }
                }
                return l;
        }
@@ -1200,37 +1174,37 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        /**
         * ??? This method is O(N*M) where N = number of methods and M is number of inter-type declarations in my super
         */
-       public List getInterTypeMungersIncludingSupers() {
-               ArrayList ret = new ArrayList();
+       public List<ConcreteTypeMunger> getInterTypeMungersIncludingSupers() {
+               ArrayList<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>();
                collectInterTypeMungers(ret);
                return ret;
        }
 
-       public List getInterTypeParentMungersIncludingSupers() {
-               ArrayList ret = new ArrayList();
+       public List<ConcreteTypeMunger> getInterTypeParentMungersIncludingSupers() {
+               ArrayList<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>();
                collectInterTypeParentMungers(ret);
                return ret;
        }
 
-       private void collectInterTypeParentMungers(List collector) {
-               for (Iterator iter = getDirectSupertypes(); iter.hasNext();) {
-                       ResolvedType superType = (ResolvedType) iter.next();
+       private void collectInterTypeParentMungers(List<ConcreteTypeMunger> collector) {
+               for (Iterator<ResolvedType> iter = getDirectSupertypes(); iter.hasNext();) {
+                       ResolvedType superType = iter.next();
                        superType.collectInterTypeParentMungers(collector);
                }
                collector.addAll(getInterTypeParentMungers());
        }
 
-       protected void collectInterTypeMungers(List collector) {
-               for (Iterator iter = getDirectSupertypes(); iter.hasNext();) {
-                       ResolvedType superType = (ResolvedType) iter.next();
+       protected void collectInterTypeMungers(List<ConcreteTypeMunger> collector) {
+               for (Iterator<ResolvedType> iter = getDirectSupertypes(); iter.hasNext();) {
+                       ResolvedType superType = iter.next();
                        if (superType == null) {
                                throw new BCException("UnexpectedProblem: a supertype in the hierarchy for " + this.getName() + " is null");
                        }
                        superType.collectInterTypeMungers(collector);
                }
 
-               outer: for (Iterator iter1 = collector.iterator(); iter1.hasNext();) {
-                       ConcreteTypeMunger superMunger = (ConcreteTypeMunger) iter1.next();
+               outer: for (Iterator<ConcreteTypeMunger> iter1 = collector.iterator(); iter1.hasNext();) {
+                       ConcreteTypeMunger superMunger = iter1.next();
                        if (superMunger.getSignature() == null)
                                continue;
 
@@ -1248,8 +1222,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                                continue;
                        }
 
-                       for (Iterator iter = getMethods(); iter.hasNext();) {
-                               ResolvedMember method = (ResolvedMember) iter.next();
+                       for (Iterator<ResolvedMember> iter = getMethods(); iter.hasNext();) {
+                               ResolvedMember method = iter.next();
                                if (conflictingSignature(method, superMunger.getSignature())) {
                                        iter1.remove();
                                        continue outer;
@@ -1878,8 +1852,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                // ??? horribly inefficient
                // for (Iterator i =
                // System.err.println("lookup " + member + " in " + interTypeMungers);
-               for (Iterator i = interTypeMungers.iterator(); i.hasNext();) {
-                       ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
+               for (ConcreteTypeMunger m : interTypeMungers) {
                        ResolvedMember ret = m.getMatchingSyntheticMember(member);
                        if (ret != null) {
                                // System.err.println("   found: " + ret);
index b53268e00ef7487494d91dc3dedfce537700590d..ce08ad23c5976c21b2f7937229569fb8d299b04f 100644 (file)
@@ -23,7 +23,6 @@ import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -52,9 +51,9 @@ public abstract class ResolvedTypeMunger {
        // across the intertype declaration to the right type variables in the generic
        // type upon which the itd is being made.
        // might need serializing the class file for binary weaving.
-       protected List /* String */typeVariableAliases;
+       protected List<String> typeVariableAliases;
 
-       private Set /* resolvedMembers */superMethodsCalled = Collections.EMPTY_SET;
+       private Set<ResolvedMember> superMethodsCalled = Collections.emptySet();
 
        private ISourceLocation location; // Lost during serialize/deserialize !
 
@@ -131,6 +130,7 @@ public abstract class ResolvedTypeMunger {
 
        // ----
 
+       @Override
        public String toString() {
                return "ResolvedTypeMunger(" + getKind() + ", " + getSignature() + ")";
                // .superMethodsCalled + ")";
@@ -157,9 +157,8 @@ public abstract class ResolvedTypeMunger {
                }
        }
 
-       protected static Set readSuperMethodsCalled(VersionedDataInputStream s) throws IOException {
-
-               Set ret = new HashSet();
+       protected static Set<ResolvedMember> readSuperMethodsCalled(VersionedDataInputStream s) throws IOException {
+               Set<ResolvedMember> ret = new HashSet<ResolvedMember>();
                int n = s.readInt();
                if (n < 0)
                        throw new BCException("Problem deserializing type munger");
@@ -176,12 +175,11 @@ public abstract class ResolvedTypeMunger {
                        return;
                }
 
-               List ret = new ArrayList(superMethodsCalled);
+               List<ResolvedMember> ret = new ArrayList<ResolvedMember>(superMethodsCalled);
                Collections.sort(ret);
                int n = ret.size();
                s.writeInt(n);
-               for (Iterator i = ret.iterator(); i.hasNext();) {
-                       ResolvedMember m = (ResolvedMember) i.next();
+               for (ResolvedMember m : ret) {
                        m.write(s);
                }
 
@@ -264,6 +262,7 @@ public abstract class ResolvedTypeMunger {
                        throw new BCException("bad kind: " + key);
                }
 
+               @Override
                public String toString() {
                        // we want MethodDelegate to appear as Method in WeaveInfo messages
                        // TODO we may want something for fieldhost ?
@@ -298,11 +297,11 @@ public abstract class ResolvedTypeMunger {
 
        public static final String SUPER_DISPATCH_NAME = "superDispatch";
 
-       public void setSuperMethodsCalled(Set c) {
+       public void setSuperMethodsCalled(Set<ResolvedMember> c) {
                this.superMethodsCalled = c;
        }
 
-       public Set getSuperMethodsCalled() {
+       public Set<ResolvedMember> getSuperMethodsCalled() {
                return superMethodsCalled;
        }
 
@@ -334,11 +333,11 @@ public abstract class ResolvedTypeMunger {
                }
        }
 
-       protected static List readInTypeAliases(VersionedDataInputStream s) throws IOException {
+       protected static List<String> readInTypeAliases(VersionedDataInputStream s) throws IOException {
                if (s.getMajorVersion() >= AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) {
                        int count = s.readInt();
                        if (count != 0) {
-                               List aliases = new ArrayList();
+                               List<String> aliases = new ArrayList<String>();
                                for (int i = 0; i < count; i++) {
                                        aliases.add(s.readUTF());
                                }
@@ -354,14 +353,13 @@ public abstract class ResolvedTypeMunger {
                        s.writeInt(0);
                } else {
                        s.writeInt(typeVariableAliases.size());
-                       for (Iterator iter = typeVariableAliases.iterator(); iter.hasNext();) {
-                               String element = (String) iter.next();
+                       for (String element : typeVariableAliases) {
                                s.writeUTF(element);
                        }
                }
        }
 
-       public List getTypeVariableAliases() {
+       public List<String> getTypeVariableAliases() {
                return typeVariableAliases;
        }
 
index ae373a87bee2ce0ee1e9fb9e15bedcc0c8063dcc..1bef37c60201f49f100cd946dae9a20edeecfdbf 100644 (file)
@@ -68,10 +68,12 @@ public class DeclareParents extends Declare {
                return true;
        }
 
+       @Override
        public Object accept(PatternNodeVisitor visitor, Object data) {
                return visitor.visit(this, data);
        }
 
+       @Override
        public Declare parameterizeWith(Map typeVariableBindingMap, World w) {
                DeclareParents ret = new DeclareParents(child.parameterizeWith(typeVariableBindingMap, w), parents.parameterizeWith(
                                typeVariableBindingMap, w), isExtends);
@@ -79,6 +81,7 @@ public class DeclareParents extends Declare {
                return ret;
        }
 
+       @Override
        public String toString() {
                StringBuffer buf = new StringBuffer();
                buf.append("declare parents: ");
@@ -89,6 +92,7 @@ public class DeclareParents extends Declare {
                return buf.toString();
        }
 
+       @Override
        public boolean equals(Object other) {
                if (!(other instanceof DeclareParents))
                        return false;
@@ -97,6 +101,7 @@ public class DeclareParents extends Declare {
        }
 
        // ??? cache this
+       @Override
        public int hashCode() {
                int result = 23;
                result = 37 * result + child.hashCode();
@@ -104,6 +109,7 @@ public class DeclareParents extends Declare {
                return result;
        }
 
+       @Override
        public void write(DataOutputStream s) throws IOException {
                s.writeByte(Declare.PARENTS);
                child.write(s);
@@ -144,6 +150,7 @@ public class DeclareParents extends Declare {
                return false;
        }
 
+       @Override
        public void resolve(IScope scope) {
                // ScopeWithTypeVariables resolutionScope = new ScopeWithTypeVariables(typeVariablesInScope,scope);
                child = child.resolveBindings(scope, Bindings.NONE, false, false);
@@ -169,6 +176,7 @@ public class DeclareParents extends Declare {
                return this.isExtends;
        }
 
+       @Override
        public boolean isAdviceLike() {
                return false;
        }
@@ -333,13 +341,13 @@ public class DeclareParents extends Declare {
                return true;
        }
 
-       public List/* <ResolvedType> */findMatchingNewParents(ResolvedType onType, boolean reportErrors) {
+       public List<ResolvedType> findMatchingNewParents(ResolvedType onType, boolean reportErrors) {
                if (onType.isRawType())
                        onType = onType.getGenericType();
                if (!match(onType))
-                       return Collections.EMPTY_LIST;
+                       return Collections.emptyList();
 
-               List ret = new ArrayList();
+               List<ResolvedType> ret = new ArrayList<ResolvedType>();
                for (int i = 0; i < parents.size(); i++) {
                        ResolvedType t = maybeGetNewParent(onType, parents.get(i), onType.getWorld(), reportErrors);
                        if (t != null)
@@ -349,6 +357,7 @@ public class DeclareParents extends Declare {
                return ret;
        }
 
+       @Override
        public String getNameSuffix() {
                return "parents";
        }
index 5d8d35568134281eabed5253314556676f76c575..f6a44c87c74b3fad63a1a9d8272c4abb1274fef9 100644 (file)
@@ -40,6 +40,7 @@ public abstract class CommonWorldTests extends TestCase {
 
        private World world;
 
+       @Override
        public void setUp() {
                world = getWorld();
        }
@@ -160,7 +161,9 @@ public abstract class CommonWorldTests extends TestCase {
        }
 
        protected void mungersTest(ResolvedType ty, ShadowMunger[] x) {
-               TestUtil.assertSetEquals(ty + " mungers:", x, ty.getDeclaredShadowMungersArray());
+               List l = (List) ty.getDeclaredShadowMungers();
+               ShadowMunger[] array = (ShadowMunger[]) l.toArray(new ShadowMunger[l.size()]);
+               TestUtil.assertSetEquals(ty + " mungers:", x, array);
        }
 
        protected void interfaceTest(ResolvedType type, ResolvedType[] expectedInterfaces) {