diff options
author | Andy Clement <aclement@pivotal.io> | 2020-08-12 15:20:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-12 15:20:45 -0700 |
commit | b6eee2e1052116aa22ebbd3c2baf05c2b709bee5 (patch) | |
tree | 01fb5493dc348d42e4fb9fb6ce1cd41e361d666b /org.aspectj.matcher | |
parent | cacc9d5602b7bbe6192d5ff1351605dc180cc108 (diff) | |
parent | 29f947156e58f3f0c60e721d42e7f3e98de7180a (diff) | |
download | aspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.tar.gz aspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.zip |
Merge pull request #1 from larsgrefer/feature/java5
Update the code to Java 5 features
Diffstat (limited to 'org.aspectj.matcher')
63 files changed, 427 insertions, 475 deletions
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractAnnotationAJ.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractAnnotationAJ.java index 503d6b3b5..e098251d1 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractAnnotationAJ.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractAnnotationAJ.java @@ -121,10 +121,9 @@ public abstract class AbstractAnnotationAJ implements AnnotationAJ { */ private final AnnotationAJ retrieveAnnotationOnAnnotation(UnresolvedType requiredAnnotationSignature) { AnnotationAJ[] annos = type.getAnnotations(); - for (int i = 0; i < annos.length; i++) { - AnnotationAJ a = annos[i]; + for (AnnotationAJ a : annos) { if (a.getTypeSignature().equals(requiredAnnotationSignature.getSignature())) { - return annos[i]; + return a; } } return null; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java index bc4c219f2..ce3b6aa60 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java @@ -135,7 +135,7 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele AbstractReferenceTypeDelegate outerObjectType = (AbstractReferenceTypeDelegate) outerDelegate; if (outerObjectType.isNested()) { GenericSignature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass(); - for (FormalTypeParameter parentParam : parentParams) { + for (GenericSignature.FormalTypeParameter parentParam : parentParams) { typeParameters.add(parentParam); } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AjAttribute.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AjAttribute.java index 781227141..e76c88f88 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AjAttribute.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AjAttribute.java @@ -374,9 +374,9 @@ public abstract class AjAttribute { } s.writeInt(lineBreaks.length); int previous = 0; - for (int i = 0, max = lineBreaks.length; i < max; i++) { - s.writeShort(lineBreaks[i] - previous); - previous = lineBreaks[i]; + for (int lineBreak : lineBreaks) { + s.writeShort(lineBreak - previous); + previous = lineBreak; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ArrayReferenceType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ArrayReferenceType.java index aa4fa55c0..81acaadfe 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ArrayReferenceType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ArrayReferenceType.java @@ -119,8 +119,8 @@ public class ArrayReferenceType extends ReferenceType { public TypeVariable[] getTypeVariables() { if (this.typeVariables == null && componentType.getTypeVariables() != null) { this.typeVariables = componentType.getTypeVariables(); - for (int i = 0; i < this.typeVariables.length; i++) { - this.typeVariables[i].resolve(world); + for (TypeVariable typeVariable : this.typeVariables) { + typeVariable.resolve(world); } } return this.typeVariables; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/BoundedReferenceType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/BoundedReferenceType.java index e0a7a680e..ad434575a 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/BoundedReferenceType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/BoundedReferenceType.java @@ -131,14 +131,14 @@ public class BoundedReferenceType extends ReferenceType { if (kind==SUPER){ ret.append("-"); ret.append(lowerBound.getSignatureForAttribute()); - for (int i=0;i<additionalInterfaceBounds.length;i++) { - ret.append(additionalInterfaceBounds[i].getSignatureForAttribute()); + for (ReferenceType additionalInterfaceBound : additionalInterfaceBounds) { + ret.append(additionalInterfaceBound.getSignatureForAttribute()); } } else if (kind==EXTENDS) { ret.append("+"); ret.append(upperBound.getSignatureForAttribute()); - for (int i=0;i<additionalInterfaceBounds.length;i++) { - ret.append(additionalInterfaceBounds[i].getSignatureForAttribute()); + for (ReferenceType additionalInterfaceBound : additionalInterfaceBounds) { + ret.append(additionalInterfaceBound.getSignatureForAttribute()); } } else if (kind==UNBOUND) { ret.append("*"); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java index 8e41c0a82..b6ddd2e6e 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java @@ -186,8 +186,7 @@ public class CrosscuttingMembers { } // Check we haven't already got a munger for this: String signatureToLookFor = typeToExpose.getSignature(); - for (Iterator<ConcreteTypeMunger> iterator = typeMungers.iterator(); iterator.hasNext();) { - ConcreteTypeMunger cTM = iterator.next(); + for (ConcreteTypeMunger cTM : typeMungers) { ResolvedTypeMunger rTM = cTM.getMunger(); if (rTM != null && rTM instanceof ExposeTypeMunger) { String exposedType = ((ExposeTypeMunger) rTM).getExposedTypeSignature(); @@ -345,8 +344,7 @@ public class CrosscuttingMembers { Set<Object> theseTypeMungers = new HashSet<Object>(); Set<Object> otherTypeMungers = new HashSet<Object>(); if (!careAboutShadowMungers) { - for (Iterator<ConcreteTypeMunger> iter = typeMungers.iterator(); iter.hasNext();) { - Object o = iter.next(); + for (Object o : typeMungers) { if (o instanceof ConcreteTypeMunger) { ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) o; if (!typeMunger.existsToSupportShadowMunging()) { @@ -357,8 +355,7 @@ public class CrosscuttingMembers { } } - for (Iterator<ConcreteTypeMunger> iter = other.typeMungers.iterator(); iter.hasNext();) { - Object o = iter.next(); + for (Object o : other.typeMungers) { if (o instanceof ConcreteTypeMunger) { ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) o; if (!typeMunger.existsToSupportShadowMunging()) { @@ -435,15 +432,13 @@ public class CrosscuttingMembers { if (!careAboutShadowMungers) { // this means we are in front end compilation and if the differences are purely mixin parents, we can continue OK Set<DeclareParents> trimmedThis = new HashSet<DeclareParents>(); - for (Iterator<DeclareParents> iterator = declareParents.iterator(); iterator.hasNext();) { - DeclareParents decp = iterator.next(); + for (DeclareParents decp : declareParents) { if (!decp.isMixin()) { trimmedThis.add(decp); } } Set<DeclareParents> trimmedOther = new HashSet<DeclareParents>(); - for (Iterator<DeclareParents> iterator = other.declareParents.iterator(); iterator.hasNext();) { - DeclareParents decp = iterator.next(); + for (DeclareParents decp : other.declareParents) { if (!decp.isMixin()) { trimmedOther.add(decp); } @@ -490,11 +485,11 @@ public class CrosscuttingMembers { if (theseInlinedAroundMungers.size() != otherInlinedAroundMungers.size()) { return false; } - for (Iterator<ShadowMunger> iter = theseInlinedAroundMungers.iterator(); iter.hasNext();) { - Advice thisAdvice = (Advice) iter.next(); + for (ShadowMunger theseInlinedAroundMunger : theseInlinedAroundMungers) { + Advice thisAdvice = (Advice) theseInlinedAroundMunger; boolean foundIt = false; - for (Iterator<ShadowMunger> iterator = otherInlinedAroundMungers.iterator(); iterator.hasNext();) { - Advice otherAdvice = (Advice) iterator.next(); + for (ShadowMunger otherInlinedAroundMunger : otherInlinedAroundMungers) { + Advice otherAdvice = (Advice) otherInlinedAroundMunger; if (thisAdvice.equals(otherAdvice)) { if (thisAdvice.getSignature() instanceof ResolvedMemberImpl) { if (((ResolvedMemberImpl) thisAdvice.getSignature()).isEquivalentTo(otherAdvice.getSignature())) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java index 969f96ece..a3d97ea89 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java @@ -140,16 +140,14 @@ public class CrosscuttingMembersSet { // System.err.println("Looking at descendants of "+aspectType.getName()); Set<ResolvedType> knownAspects = members.keySet(); Set<ResolvedType> toBeReplaced = new HashSet<ResolvedType>(); - for (Iterator<ResolvedType> it = knownAspects.iterator(); it.hasNext();) { - ResolvedType candidateDescendant = it.next(); + for (ResolvedType candidateDescendant : knownAspects) { // allowMissing = true - if something is missing, it really probably is not a descendant if ((candidateDescendant != aspectType) && (aspectType.isAssignableFrom(candidateDescendant, true))) { toBeReplaced.add(candidateDescendant); } } boolean change = false; - for (Iterator<ResolvedType> it = toBeReplaced.iterator(); it.hasNext();) { - ResolvedType next = it.next(); + for (ResolvedType next : toBeReplaced) { boolean thisChange = addOrReplaceAspect(next, inWeavePhase); change = change || thisChange; } @@ -195,8 +193,8 @@ public class CrosscuttingMembersSet { public List<ShadowMunger> getShadowMungers() { if (shadowMungers == null) { List<ShadowMunger> ret = new ArrayList<ShadowMunger>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getShadowMungers()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getShadowMungers()); } shadowMungers = ret; } @@ -283,8 +281,8 @@ public class CrosscuttingMembersSet { public List<ConcreteTypeMunger> getLateTypeMungers() { if (lateTypeMungers == null) { List<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getLateTypeMungers()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getLateTypeMungers()); } lateTypeMungers = ret; } @@ -294,8 +292,8 @@ public class CrosscuttingMembersSet { public List<DeclareSoft> getDeclareSofts() { if (declareSofts == null) { Set<DeclareSoft> ret = new HashSet<DeclareSoft>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareSofts()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareSofts()); } declareSofts = new ArrayList<DeclareSoft>(); declareSofts.addAll(ret); @@ -306,8 +304,8 @@ public class CrosscuttingMembersSet { public List<DeclareParents> getDeclareParents() { if (declareParents == null) { Set<DeclareParents> ret = new HashSet<DeclareParents>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareParents()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareParents()); } declareParents = new ArrayList<DeclareParents>(); declareParents.addAll(ret); @@ -321,8 +319,8 @@ public class CrosscuttingMembersSet { public List<DeclareAnnotation> getDeclareAnnotationOnTypes() { if (declareAnnotationOnTypes == null) { Set<DeclareAnnotation> ret = new LinkedHashSet<DeclareAnnotation>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareAnnotationOnTypes()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareAnnotationOnTypes()); } declareAnnotationOnTypes = new ArrayList<DeclareAnnotation>(); declareAnnotationOnTypes.addAll(ret); @@ -336,8 +334,8 @@ public class CrosscuttingMembersSet { public List<DeclareAnnotation> getDeclareAnnotationOnFields() { if (declareAnnotationOnFields == null) { Set<DeclareAnnotation> ret = new LinkedHashSet<DeclareAnnotation>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareAnnotationOnFields()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareAnnotationOnFields()); } declareAnnotationOnFields = new ArrayList<DeclareAnnotation>(); declareAnnotationOnFields.addAll(ret); @@ -351,8 +349,8 @@ public class CrosscuttingMembersSet { public List<DeclareAnnotation> getDeclareAnnotationOnMethods() { if (declareAnnotationOnMethods == null) { Set<DeclareAnnotation> ret = new LinkedHashSet<DeclareAnnotation>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareAnnotationOnMethods()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareAnnotationOnMethods()); } declareAnnotationOnMethods = new ArrayList<DeclareAnnotation>(); declareAnnotationOnMethods.addAll(ret); @@ -367,8 +365,8 @@ public class CrosscuttingMembersSet { public List<DeclareTypeErrorOrWarning> getDeclareTypeEows() { if (declareTypeEows == null) { Set<DeclareTypeErrorOrWarning> ret = new HashSet<DeclareTypeErrorOrWarning>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareTypeErrorOrWarning()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareTypeErrorOrWarning()); } declareTypeEows = new ArrayList<DeclareTypeErrorOrWarning>(); declareTypeEows.addAll(ret); @@ -379,8 +377,8 @@ public class CrosscuttingMembersSet { public List<Declare> getDeclareDominates() { if (declareDominates == null) { List<Declare> ret = new ArrayList<Declare>(); - for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareDominates()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareDominates()); } declareDominates = ret; } @@ -389,10 +387,8 @@ public class CrosscuttingMembersSet { public ResolvedType findAspectDeclaringParents(DeclareParents p) { Set<ResolvedType> keys = this.members.keySet(); - for (Iterator<ResolvedType> iter = keys.iterator(); iter.hasNext();) { - ResolvedType element = iter.next(); - for (Iterator i = members.get(element).getDeclareParents().iterator(); i.hasNext();) { - DeclareParents dp = (DeclareParents) i.next(); + for (ResolvedType element : keys) { + for (DeclareParents dp : members.get(element).getDeclareParents()) { if (dp.equals(p)) { return element; } @@ -428,8 +424,7 @@ public class CrosscuttingMembersSet { if (verificationList == null) { return; } - for (Iterator<IVerificationRequired> iter = verificationList.iterator(); iter.hasNext();) { - IVerificationRequired element = iter.next(); + for (IVerificationRequired element : verificationList) { element.verify(); } verificationList = null; @@ -440,8 +435,7 @@ public class CrosscuttingMembersSet { public void write(CompressingDataOutputStream stream) throws IOException { // stream.writeInt(serializationVersion); stream.writeInt(shadowMungers.size()); - for (Iterator iterator = shadowMungers.iterator(); iterator.hasNext();) { - ShadowMunger shadowMunger = (ShadowMunger) iterator.next(); + for (ShadowMunger shadowMunger : shadowMungers) { shadowMunger.write(stream); } // // private List /* ShadowMunger */shadowMungers = null; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java index 0efd56782..2e2f9e9df 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java @@ -372,8 +372,7 @@ public class Dump { private void dumpCompilerMessages(IMessageHolder messageHolder) { println("---- Compiler Messages ---"); if (messageHolder != null) { - for (Iterator<IMessage> i = messageHolder.getUnmodifiableListView().iterator(); i.hasNext();) { - IMessage message = i.next(); + for (IMessage message : messageHolder.getUnmodifiableListView()) { println(message.toString()); } } else { @@ -419,15 +418,14 @@ public class Dump { return; } - for (int i = 0; i < array.length; i++) { - print.println(array[i]); + for (Object o : array) { + print.println(o); } } private void println(Properties props) { - Iterator iter = props.keySet().iterator(); - while (iter.hasNext()) { - String key = (String) iter.next(); + for (Object o : props.keySet()) { + String key = (String) o; String value = props.getProperty(key); print.println(key + "=" + value); } @@ -454,8 +452,7 @@ public class Dump { if (list == null || list.isEmpty()) { println(NULL_OR_EMPTY); } else { - for (Iterator i = list.iterator(); i.hasNext();) { - Object o = i.next(); + for (Object o : list) { if (o instanceof Exception) { println((Exception) o); } else { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java index aab34b8f6..7307ab93c 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java @@ -234,8 +234,8 @@ public class Lint { @SuppressWarnings("rawtypes") public void setFromProperties(Properties properties) { - for (Iterator i = properties.entrySet().iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); + for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) { + Map.Entry entry = (Map.Entry) objectObjectEntry; Kind kind = kinds.get(entry.getKey()); if (kind == null) { MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_KEY_ERROR, entry.getKey())); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java index fbf497ed2..9e608c9ad 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java @@ -127,8 +127,8 @@ public class MemberImpl implements Member { public static String typesToSignature(UnresolvedType[] paramTypes) { StringBuffer buf = new StringBuffer(); buf.append("("); - for (int i = 0; i < paramTypes.length; i++) { - buf.append(paramTypes[i].getSignature()); + for (UnresolvedType paramType : paramTypes) { + buf.append(paramType.getSignature()); } buf.append(")"); return buf.toString(); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MethodDelegateTypeMunger.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MethodDelegateTypeMunger.java index bf8a76529..d07d8456f 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MethodDelegateTypeMunger.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MethodDelegateTypeMunger.java @@ -114,8 +114,7 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { public ResolvedMember getDelegateFactoryMethod(World w) { ResolvedType aspectType = w.resolve(aspect); ResolvedMember[] methods = aspectType.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - ResolvedMember rm = methods[i]; + for (ResolvedMember rm : methods) { if (rm.getName().equals(factoryMethodName) && rm.getSignature().equals(factoryMethodSignature)) { return rm; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java index f9162684a..a2b2f5d1c 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java @@ -72,7 +72,7 @@ public class NameMangler { return false; // body of an itd-m } return true; - } else if (methodName.indexOf("_aroundBody") != -1) { + } else if (methodName.contains("_aroundBody")) { return true; } // these aren't the droids you're looking for...move along...... pr148727 diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ReferenceType.java index 7dc162a16..aad9a1dbe 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ReferenceType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ReferenceType.java @@ -225,8 +225,8 @@ public class ReferenceType extends ResolvedType { return true; } if (annotationTypes != null) { - for (int i = 0; i < annotationTypes.length; i++) { - if (annotationTypes[i].equals(ofType)) { + for (ResolvedType annotationType : annotationTypes) { + if (annotationType.equals(ofType)) { return true; } } @@ -278,17 +278,17 @@ public class ReferenceType extends ResolvedType { public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) { AnnotationAJ[] axs = getDelegate().getAnnotations(); if (axs != null) { - for (int i = 0; i < axs.length; i++) { - if (axs[i].getTypeSignature().equals(ofType.getSignature())) { - return axs[i]; + for (AnnotationAJ ax : axs) { + if (ax.getTypeSignature().equals(ofType.getSignature())) { + return ax; } } } if (annotations != null) { String searchSig = ofType.getSignature(); - for (int i = 0; i < annotations.length; i++) { - if (annotations[i].getTypeSignature().equals(searchSig)) { - return annotations[i]; + for (AnnotationAJ annotation : annotations) { + if (annotation.getTypeSignature().equals(searchSig)) { + return annotation; } } } @@ -386,9 +386,9 @@ public class ReferenceType extends ResolvedType { // ??? needs to be Methods, not just declared methods? JLS 5.5 unclear ResolvedMember[] a = getDeclaredMethods(); ResolvedMember[] b = other.getDeclaredMethods(); - for (int ai = 0, alen = a.length; ai < alen; ai++) { - for (int bi = 0, blen = b.length; bi < blen; bi++) { - if (!b[bi].isCompatibleWith(a[ai])) { + for (ResolvedMember member : a) { + for (ResolvedMember resolvedMember : b) { + if (!resolvedMember.isCompatibleWith(member)) { return false; } } @@ -507,11 +507,11 @@ public class ReferenceType extends ResolvedType { if (((ReferenceType) this.getRawType()).isAssignableFrom(other)) { boolean wildcardsAllTheWay = true; ResolvedType[] myParameters = this.getResolvedTypeParameters(); - for (int i = 0; i < myParameters.length; i++) { - if (!myParameters[i].isGenericWildcard()) { + for (ResolvedType myParameter : myParameters) { + if (!myParameter.isGenericWildcard()) { wildcardsAllTheWay = false; } else { - BoundedReferenceType boundedRT = (BoundedReferenceType) myParameters[i]; + BoundedReferenceType boundedRT = (BoundedReferenceType) myParameter; if (boundedRT.isExtends() || boundedRT.isSuper()) { wildcardsAllTheWay = false; } @@ -910,8 +910,8 @@ public class ReferenceType extends ResolvedType { public TypeVariable[] getTypeVariables() { if (typeVariables == null) { typeVariables = getDelegate().getTypeVariables(); - for (int i = 0; i < this.typeVariables.length; i++) { - typeVariables[i].resolve(world); + for (TypeVariable typeVariable : this.typeVariables) { + typeVariable.resolve(world); } } return typeVariables; @@ -1131,8 +1131,8 @@ public class ReferenceType extends ResolvedType { ret.append(PARAMETERIZED_TYPE_IDENTIFIER); ret.append(rawSignature.substring(1, rawSignature.length() - 1)); ret.append("<"); - for (int i = 0; i < someParameters.length; i++) { - ret.append(someParameters[i].getSignature()); + for (ResolvedType someParameter : someParameters) { + ret.append(someParameter.getSignature()); } ret.append(">;"); return ret.toString(); @@ -1144,18 +1144,18 @@ public class ReferenceType extends ResolvedType { String rawSig = aGenericType.getErasureSignature(); ret.append(rawSig.substring(0, rawSig.length() - 1)); ret.append("<"); - for (int i = 0; i < someParameters.length; i++) { - if (someParameters[i] instanceof ReferenceType) { - ret.append(((ReferenceType) someParameters[i]) + for (UnresolvedType someParameter : someParameters) { + if (someParameter instanceof ReferenceType) { + ret.append(((ReferenceType) someParameter) .getSignatureForAttribute()); - } else if (someParameters[i] instanceof Primitive) { - ret.append(((Primitive) someParameters[i]) + } else if (someParameter instanceof Primitive) { + ret.append(((Primitive) someParameter) .getSignatureForAttribute()); } else { throw new IllegalStateException( "DebugFor325731: expected a ReferenceType or Primitive but was " - + someParameters[i] + " of type " - + someParameters[i].getClass().getName()); + + someParameter + " of type " + + someParameter.getClass().getName()); } } ret.append(">;"); @@ -1200,8 +1200,8 @@ public class ReferenceType extends ResolvedType { } else { ResolvedType[] existing = getDelegate().getDeclaredInterfaces(); if (existing != null) { - for (int i = 0; i < existing.length; i++) { - if (existing[i].equals(newParent)) { + for (ResolvedType resolvedType : existing) { + if (resolvedType.equals(newParent)) { return; // already has this interface } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java index 84e382422..bb609f104 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java @@ -289,8 +289,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso return backingGenericMember.hasAnnotation(ofType); } if (annotationTypes != null) { - for (int i = 0, max = annotationTypes.length; i < max; i++) { - if (annotationTypes[i].equals(ofType)) { + for (ResolvedType annotationType : annotationTypes) { + if (annotationType.equals(ofType)) { return true; } } @@ -434,8 +434,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso s.writeByte(0); } else { s.writeByte(typeVariables.length); - for (int i = 0; i < typeVariables.length; i++) { - typeVariables[i].write(s); + for (TypeVariable typeVariable : typeVariables) { + typeVariable.write(s); } } String gsig = getGenericSignature(); @@ -445,11 +445,11 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso s.writeByte(0xff); } else { s.writeByte(parameterTypes.length); - for (int i = 0; i < parameterTypes.length; i++) { + for (UnresolvedType parameterType : parameterTypes) { if (s.canCompress()) { - s.writeCompressedSignature(parameterTypes[i].getSignature()); + s.writeCompressedSignature(parameterType.getSignature()); } else { - UnresolvedType array_element = parameterTypes[i]; + UnresolvedType array_element = parameterType; array_element.write(s); } } @@ -471,16 +471,16 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso StringBuffer sb = new StringBuffer(); if (typeVariables != null) { sb.append("<"); - for (int i = 0; i < typeVariables.length; i++) { - sb.append(typeVariables[i].getSignatureForAttribute()); // need + for (TypeVariable typeVariable : typeVariables) { + sb.append(typeVariable.getSignatureForAttribute()); // need // a // 'getSignatureForAttribute()' } sb.append(">"); } sb.append("("); - for (int i = 0; i < parameterTypes.length; i++) { - ResolvedType ptype = (ResolvedType) parameterTypes[i]; + for (UnresolvedType parameterType : parameterTypes) { + ResolvedType ptype = (ResolvedType) parameterType; sb.append(ptype.getSignatureForAttribute()); } sb.append(")"); @@ -492,14 +492,13 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso StringBuffer sb = new StringBuffer(); if (typeVariables != null) { sb.append("<"); - for (int i = 0; i < typeVariables.length; i++) { - sb.append(typeVariables[i].getSignature()); + for (TypeVariable typeVariable : typeVariables) { + sb.append(typeVariable.getSignature()); } sb.append(">"); } sb.append("("); - for (int i = 0; i < parameterTypes.length; i++) { - UnresolvedType ptype = parameterTypes[i]; + for (UnresolvedType ptype : parameterTypes) { sb.append(ptype.getSignature()); } sb.append(")"); @@ -509,8 +508,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso public static void writeArray(ResolvedMember[] members, CompressingDataOutputStream s) throws IOException { s.writeInt(members.length); - for (int i = 0, len = members.length; i < len; i++) { - members[i].write(s); + for (ResolvedMember member : members) { + member.write(s); } } @@ -756,7 +755,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso // check going bang in this case we check for $ (crap...) - we can't check the outer because the declaring type // is considered unresolved... if (// isParameterized && <-- might need this bit... - !getDeclaringType().isGenericType() && getDeclaringType().getName().indexOf("$") == -1) { + !getDeclaringType().isGenericType() && !getDeclaringType().getName().contains("$")) { throw new IllegalStateException("Can't ask to parameterize a member of non-generic type: " + getDeclaringType() + " kind(" + getDeclaringType().typeKind + ")"); } @@ -1058,8 +1057,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso } StringBuffer sig = new StringBuffer(); UnresolvedType[] myParameterTypes = getGenericParameterTypes(); - for (int i = 0; i < myParameterTypes.length; i++) { - appendSigWithTypeVarBoundsRemoved(myParameterTypes[i], sig, new HashSet<UnresolvedType>()); + for (UnresolvedType myParameterType : myParameterTypes) { + appendSigWithTypeVarBoundsRemoved(myParameterType, sig, new HashSet<UnresolvedType>()); } myParameterSignatureWithBoundsRemoved = sig.toString(); return myParameterSignatureWithBoundsRemoved; @@ -1239,9 +1238,9 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso public TypeVariable getTypeVariableNamed(String name) { // Check locally... if (typeVariables != null) { - for (int i = 0; i < typeVariables.length; i++) { - if (typeVariables[i].getName().equals(name)) { - return typeVariables[i]; + for (TypeVariable typeVariable : typeVariables) { + if (typeVariable.getName().equals(name)) { + return typeVariable; } } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java index 98400ebdc..8e48b02d4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java @@ -437,8 +437,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } // Go through the interfaces on the way back down ResolvedType[] interfaces = resolvedType.getDeclaredInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - ResolvedType iface = interfaces[i]; + for (ResolvedType anInterface : interfaces) { + ResolvedType iface = anInterface; if (!genericsAware && iface.isParameterizedOrGenericType()) { iface = iface.getRawType(); } @@ -487,8 +487,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } // Go through the interfaces on the way back down ResolvedType[] interfaces = resolvedType.getDeclaredInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - ResolvedType iface = interfaces[i]; + for (ResolvedType anInterface : interfaces) { + ResolvedType iface = anInterface; if (!genericsAware && (iface.isParameterizedType() || iface.isGenericType())) { iface = iface.getRawType(); } @@ -562,8 +562,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl if (!type.isMissing()) { ResolvedMember[] methods = type.getDeclaredMethods(); if (methods != null) { - for (int i = 0; i < methods.length; i++) { - ResolvedMember method = methods[i]; + for (ResolvedMember method : methods) { if (matches(method, m)) { return method; } @@ -584,8 +583,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl // Queue any interfaces not already checked: ResolvedType[] superinterfaces = type.getDeclaredInterfaces(); if (superinterfaces != null) { - for (int i = 0; i < superinterfaces.length; i++) { - ResolvedType interf = superinterfaces[i]; + for (ResolvedType interf : superinterfaces) { if (!typesTolookat.contains(interf)) { typesTolookat.add(interf); } @@ -612,8 +610,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl * return null if not found */ private ResolvedMember lookupMember(Member m, ResolvedMember[] a) { - for (int i = 0; i < a.length; i++) { - ResolvedMember f = a[i]; + for (ResolvedMember f : a) { if (matches(f, m)) { return f; } @@ -833,8 +830,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl while (typeIterator.hasNext()) { ResolvedType ty = typeIterator.next(); // System.out.println("super: " + ty + ", " + ); - for (Iterator<Declare> i = ty.getDeclares().iterator(); i.hasNext();) { - Declare dec = i.next(); + for (Declare dec : ty.getDeclares()) { if (dec.isAdviceLike()) { if (includeAdviceLike) { ret.add(dec); @@ -979,7 +975,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } public boolean isSynthetic() { - return signature.indexOf("$ajc") != -1; + return signature.contains("$ajc"); } public final boolean isFinal() { @@ -1031,8 +1027,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl methods = getGenericType().getDeclaredMethods(); } Map<String, UnresolvedType> typeVariableMap = getAjMemberParameterizationMap(); - for (int i = 0, len = methods.length; i < len; i++) { - ShadowMunger munger = methods[i].getAssociatedShadowMunger(); + for (ResolvedMember method : methods) { + ShadowMunger munger = method.getAssociatedShadowMunger(); if (munger != null) { if (ajMembersNeedParameterization()) { // munger.setPointcut(munger.getPointcut().parameterizeWith( @@ -1041,7 +1037,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl if (munger instanceof Advice) { Advice advice = (Advice) munger; // update to use the parameterized signature... - UnresolvedType[] ptypes = methods[i].getGenericParameterTypes(); + UnresolvedType[] ptypes = method.getGenericParameterTypes(); UnresolvedType[] newPTypes = new UnresolvedType[ptypes.length]; for (int j = 0; j < ptypes.length; j++) { if (ptypes[j] instanceof TypeVariableReferenceType) { @@ -1081,9 +1077,9 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl private ResolvedMember[] filterInJavaVisible(ResolvedMember[] ms) { List<ResolvedMember> l = new ArrayList<ResolvedMember>(); - for (int i = 0, len = ms.length; i < len; i++) { - if (!ms[i].isAjSynthetic() && ms[i].getAssociatedShadowMunger() == null) { - l.add(ms[i]); + for (ResolvedMember m : ms) { + if (!m.isAjSynthetic() && m.getAssociatedShadowMunger() == null) { + l.add(m); } } return l.toArray(new ResolvedMember[l.size()]); @@ -1398,8 +1394,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl if (ret == null) { // try interfaces then, but only ITDs now... ResolvedType[] superInterfaces = onType.getDeclaredInterfaces(); - for (int i = 0; i < superInterfaces.length; i++) { - ret = superInterfaces[i].lookupMethodInITDs(member); + for (ResolvedType superInterface : superInterfaces) { + ret = superInterface.lookupMethodInITDs(member); if (ret != null) { return ret; } @@ -1646,8 +1642,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } ResolvedType[] superIs = getDeclaredInterfaces(); - for (int i = 0; i < superIs.length; i++) { - ResolvedType superI = superIs[i]; + for (ResolvedType superI : superIs) { if (superI.genericTypeEquals(lookingFor)) { return superI; } @@ -2128,17 +2123,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl ResolvedType runtimeException = world.resolve("java.lang.RuntimeException"); ResolvedType error = world.resolve("java.lang.Error"); - outer: for (int i = 0, leni = childExceptions.length; i < leni; i++) { + outer: + for (ResolvedType childException : childExceptions) { // System.err.println("checking: " + childExceptions[i]); - if (runtimeException.isAssignableFrom(childExceptions[i])) { + if (runtimeException.isAssignableFrom(childException)) { continue; } - if (error.isAssignableFrom(childExceptions[i])) { + if (error.isAssignableFrom(childException)) { continue; } - for (int j = 0, lenj = parentExceptions.length; j < lenj; j++) { - if (parentExceptions[j].isAssignableFrom(childExceptions[i])) { + for (ResolvedType parentException : parentExceptions) { + if (parentException.isAssignableFrom(childException)) { continue outer; } } @@ -2439,9 +2435,9 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } private void addPointcutsResolvingConflicts(List<ResolvedMember> acc, List<ResolvedMember> added, boolean isOverriding) { - for (Iterator<ResolvedMember> i = added.iterator(); i.hasNext();) { - ResolvedPointcutDefinition toAdd = (ResolvedPointcutDefinition) i.next(); - for (Iterator<ResolvedMember> j = acc.iterator(); j.hasNext();) { + for (ResolvedMember resolvedMember : added) { + ResolvedPointcutDefinition toAdd = (ResolvedPointcutDefinition) resolvedMember; + for (Iterator<ResolvedMember> j = acc.iterator(); j.hasNext(); ) { ResolvedPointcutDefinition existing = (ResolvedPointcutDefinition) j.next(); if (toAdd == null || existing == null || existing == toAdd) { continue; @@ -2527,8 +2523,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl return this; } boolean workToDo = false; - for (int i = 0; i < typeParameters.length; i++) { - if (typeParameters[i].isTypeVariableReference() || (typeParameters[i] instanceof BoundedReferenceType) || typeParameters[i].isParameterizedType()) { + for (UnresolvedType typeParameter : typeParameters) { + if (typeParameter.isTypeVariableReference() || (typeParameter instanceof BoundedReferenceType) || typeParameter.isParameterizedType()) { workToDo = true; } } @@ -2720,22 +2716,22 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl return false; } - for (int i = 0; i < typeParameters.length; i++) { - ResolvedType aType = (ResolvedType) typeParameters[i]; + for (UnresolvedType typeParameter : typeParameters) { + ResolvedType aType = (ResolvedType) typeParameter; if (aType.isTypeVariableReference() - // Changed according to the problems covered in bug 222648 - // Don't care what kind of type variable - the fact that there - // is one - // at all means we can't risk caching it against we get confused - // later - // by another variation of the parameterization that just - // happens to - // use the same type variable name - - // assume the worst - if its definetly not a type declared one, - // it could be anything - // && ((TypeVariableReference)aType).getTypeVariable(). - // getDeclaringElementKind()!=TypeVariable.TYPE + // Changed according to the problems covered in bug 222648 + // Don't care what kind of type variable - the fact that there + // is one + // at all means we can't risk caching it against we get confused + // later + // by another variation of the parameterization that just + // happens to + // use the same type variable name + + // assume the worst - if its definetly not a type declared one, + // it could be anything + // && ((TypeVariableReference)aType).getTypeVariable(). + // getDeclaringElementKind()!=TypeVariable.TYPE ) { parameterizedWithTypeVariable = FuzzyBoolean.YES; return true; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedTypeMunger.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedTypeMunger.java index 2ba3cbc36..86e06e767 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedTypeMunger.java @@ -217,8 +217,8 @@ public abstract class ResolvedTypeMunger { File f = (File) ois.readObject(); Integer ii = (Integer) ois.readObject(); Integer offset = (Integer) ois.readObject(); - ret = new SourceLocation(f, ii.intValue()); - ret.setOffset(offset.intValue()); + ret = new SourceLocation(f, ii); + ret.setOffset(offset); } } else { boolean validLocation = b == 2; @@ -259,11 +259,11 @@ public abstract class ResolvedTypeMunger { } else { s.writeByte(0); ObjectOutputStream oos = new ObjectOutputStream(s); - oos.writeObject(new Boolean(location != null)); + oos.writeObject(location != null); if (location != null) { oos.writeObject(location.getSourceFile()); - oos.writeObject(new Integer(location.getLine())); - oos.writeObject(new Integer(location.getOffset())); + oos.writeObject(location.getLine()); + oos.writeObject(location.getOffset()); } oos.flush(); oos.close(); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java index cde7e5163..1892e8940 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java @@ -350,11 +350,11 @@ public abstract class Shadow { */ public static int howMany(int i) { int count = 0; - for (int j = 0; j < SHADOW_KINDS.length; j++) { - if ((i & SHADOW_KINDS[j].bit) != 0) { - count++; - } - } + for (Kind shadowKind : SHADOW_KINDS) { + if ((i & shadowKind.bit) != 0) { + count++; + } + } return count; } @@ -487,11 +487,11 @@ public abstract class Shadow { */ protected boolean checkMunger(ShadowMunger munger) { if (munger.mustCheckExceptions()) { - for (Iterator<ResolvedType> i = munger.getThrownExceptions().iterator(); i.hasNext();) { - if (!checkCanThrow(munger, i.next())) { - return false; - } - } + for (ResolvedType resolvedType : munger.getThrownExceptions()) { + if (!checkCanThrow(munger, resolvedType)) { + return false; + } + } } return true; } @@ -522,11 +522,11 @@ public abstract class Shadow { private boolean isDeclaredException(ResolvedType resolvedTypeX, Member member) { ResolvedType[] excs = getIWorld().resolve(member.getExceptions(getIWorld())); - for (int i = 0, len = excs.length; i < len; i++) { - if (excs[i].isAssignableFrom(resolvedTypeX)) { - return true; - } - } + for (ResolvedType exc : excs) { + if (exc.isAssignableFrom(resolvedTypeX)) { + return true; + } + } return false; } @@ -596,7 +596,7 @@ public abstract class Shadow { // Ask the world if it knows about precedence between these Integer order = getIWorld().getPrecedenceIfAny(adviceA.concreteAspect, adviceB.concreteAspect); - if (order != null && order.equals(new Integer(0))) { + if (order != null && order.equals(0)) { String key = adviceA.getDeclaringAspect() + ":" + adviceB.getDeclaringAspect(); String possibleExistingKey = adviceB.getDeclaringAspect() + ":" + adviceA.getDeclaringAspect(); if (!clashingAspects.contains(possibleExistingKey)) { @@ -608,13 +608,12 @@ public abstract class Shadow { } } } - for (Iterator<String> iter = clashingAspects.iterator(); iter.hasNext();) { - String element = iter.next(); - String aspect1 = element.substring(0, element.indexOf(":")); - String aspect2 = element.substring(element.indexOf(":") + 1); - getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[] { this.toString(), aspect1, aspect2 }, - this.getSourceLocation(), null); - } + for (String element : clashingAspects) { + String aspect1 = element.substring(0, element.indexOf(":")); + String aspect2 = element.substring(element.indexOf(":") + 1); + getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[]{this.toString(), aspect1, aspect2}, + this.getSourceLocation(), null); + } } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java index a0e49becc..809cc58de 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java @@ -213,7 +213,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH // grab javaclass... but it doesnt know the originating file // } } - if (binaryPath.indexOf("!") == -1) { + if (!binaryPath.contains("!")) { File f = getDeclaringType().getSourceLocation().getSourceFile(); // Replace the source file suffix with .class int i = f.getPath().lastIndexOf('.'); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SignatureUtils.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SignatureUtils.java index d32f7d99f..b88084a47 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SignatureUtils.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SignatureUtils.java @@ -219,8 +219,8 @@ public class SignatureUtils { if (types == null) return ""; StringBuffer buf = new StringBuffer(); - for (int i = 0, len = types.length; i < len; i++) { - buf.append(makeString(types[i])); + for (UnresolvedType type : types) { + buf.append(makeString(type)); buf.append(':'); } return buf.toString(); @@ -230,8 +230,8 @@ public class SignatureUtils { if (names == null) return ""; StringBuffer buf = new StringBuffer(); - for (int i = 0, len = names.length; i < len; i++) { - buf.append(names[i]); + for (String name : names) { + buf.append(name); buf.append(':'); } return buf.toString(); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java index 27af4e8f5..32e55f6b4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java @@ -21,31 +21,31 @@ public class SimpleAnnotationValue extends AnnotationValue { super(kind); switch (kind) { case AnnotationValue.PRIMITIVE_BYTE: - theByte = ((Byte) value).byteValue(); + theByte = (Byte) value; break; case AnnotationValue.PRIMITIVE_CHAR: - theChar = ((Character) value).charValue(); + theChar = (Character) value; break; case AnnotationValue.PRIMITIVE_INT: - theInt = ((Integer) value).intValue(); + theInt = (Integer) value; break; case AnnotationValue.STRING: theString = (String) value; break; case AnnotationValue.PRIMITIVE_DOUBLE: - theDouble = ((Double) value).doubleValue(); + theDouble = (Double) value; break; case AnnotationValue.PRIMITIVE_FLOAT: - theFloat = ((Float) value).floatValue(); + theFloat = (Float) value; break; case AnnotationValue.PRIMITIVE_LONG: - theLong = ((Long) value).longValue(); + theLong = (Long) value; break; case AnnotationValue.PRIMITIVE_SHORT: - theShort = ((Short) value).shortValue(); + theShort = (Short) value; break; case AnnotationValue.PRIMITIVE_BOOLEAN: - theBoolean = ((Boolean) value).booleanValue(); + theBoolean = (Boolean) value; break; default: throw new BCException("Not implemented for this kind: " + whatKindIsThis(kind)); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/StandardAnnotation.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/StandardAnnotation.java index 475b0977f..5c898552d 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/StandardAnnotation.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/StandardAnnotation.java @@ -81,8 +81,7 @@ public class StandardAnnotation extends AbstractAnnotationAJ { if (nvPairs == null) { return false; } - for (int i = 0; i < nvPairs.size(); i++) { - AnnotationNameValuePair pair = nvPairs.get(i); + for (AnnotationNameValuePair pair : nvPairs) { if (pair.getName().equals(n)) { return true; } @@ -97,8 +96,7 @@ public class StandardAnnotation extends AbstractAnnotationAJ { if (nvPairs == null) { return false; } - for (int i = 0; i < nvPairs.size(); i++) { - AnnotationNameValuePair pair = nvPairs.get(i); + for (AnnotationNameValuePair pair : nvPairs) { if (pair.getName().equals(n)) { if (pair.getValue().stringify().equals(v)) { return true; @@ -119,8 +117,8 @@ public class StandardAnnotation extends AbstractAnnotationAJ { ArrayAnnotationValue aav = (ArrayAnnotationValue) nvp.getValue(); AnnotationValue[] avs = aav.getValues(); Set<String> targets = new HashSet<String>(); - for (int i = 0; i < avs.length; i++) { - EnumAnnotationValue value = (EnumAnnotationValue)avs[i]; + for (AnnotationValue av : avs) { + EnumAnnotationValue value = (EnumAnnotationValue) av; targets.add(value.getValue()); } return targets; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeFactory.java index e565e5bc8..2a578e392 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeFactory.java @@ -366,8 +366,8 @@ public class TypeFactory { parameterizedSig.append(baseTypeSignature.substring(1, baseTypeSignature.length() - 1)); if (arguments.length > 0) { parameterizedSig.append("<"); - for (int i = 0; i < arguments.length; i++) { - parameterizedSig.append(arguments[i].getSignature()); + for (UnresolvedType argument : arguments) { + parameterizedSig.append(argument.getSignature()); } parameterizedSig.append(">"); } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariable.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariable.java index d67bbd8dc..d9bd8c50c 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariable.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariable.java @@ -113,9 +113,9 @@ public class TypeVariable { UnresolvedType declaring = (UnresolvedType) declaringElement; ReferenceType rd = (ReferenceType) declaring.resolve(world); TypeVariable[] tVars = rd.getTypeVariables(); - for (int i = 0; i < tVars.length; i++) { - if (tVars[i].getName().equals(getName())) { - resolvedTVar = tVars[i]; + for (TypeVariable tVar : tVars) { + if (tVar.getName().equals(getName())) { + resolvedTVar = tVar; break; } } @@ -123,9 +123,9 @@ public class TypeVariable { // look for type variable on method... ResolvedMember declaring = (ResolvedMember) declaringElement; TypeVariable[] tvrts = declaring.getTypeVariables(); - for (int i = 0; i < tvrts.length; i++) { - if (tvrts[i].getName().equals(getName())) { - resolvedTVar = tvrts[i]; + for (TypeVariable tvrt : tvrts) { + if (tvrt.getName().equals(getName())) { + resolvedTVar = tvrt; // if (tvrts[i].isTypeVariableReference()) { // TypeVariableReferenceType tvrt = (TypeVariableReferenceType) tvrts[i].resolve(inSomeWorld); // TypeVariable tv = tvrt.getTypeVariable(); @@ -187,8 +187,8 @@ public class TypeVariable { return false; } // candidate is a subtype of all superInterfaces - for (int i = 0; i < superInterfaces.length; i++) { - if (!isASubtypeOf(superInterfaces[i], candidate)) { + for (UnresolvedType superInterface : superInterfaces) { + if (!isASubtypeOf(superInterface, candidate)) { return false; } } @@ -230,10 +230,10 @@ public class TypeVariable { ret.append(" extends "); ret.append(getFirstBound().getName()); if (superInterfaces != null) { - for (int i = 0; i < superInterfaces.length; i++) { - if (!getFirstBound().equals(superInterfaces[i])) { + for (UnresolvedType superInterface : superInterfaces) { + if (!getFirstBound().equals(superInterface)) { ret.append(" & "); - ret.append(superInterfaces[i].getName()); + ret.append(superInterface.getName()); } } } @@ -258,9 +258,9 @@ public class TypeVariable { sb.append(superclass.getSignature()); } if (superInterfaces.length != 0) { - for (int i = 0; i < superInterfaces.length; i++) { + for (UnresolvedType superInterface : superInterfaces) { sb.append(":"); - UnresolvedType iBound = superInterfaces[i]; + UnresolvedType iBound = superInterface; sb.append(iBound.getSignature()); } } @@ -278,9 +278,9 @@ public class TypeVariable { sb.append(((ReferenceType)superclass).getSignatureForAttribute()); } if (superInterfaces.length != 0) { - for (int i = 0; i < superInterfaces.length; i++) { + for (UnresolvedType superInterface : superInterfaces) { sb.append(":"); - ResolvedType iBound = (ResolvedType) superInterfaces[i]; + ResolvedType iBound = (ResolvedType) superInterface; sb.append(iBound.getSignatureForAttribute()); } } @@ -325,8 +325,7 @@ public class TypeVariable { s.writeInt(0); } else { s.writeInt(superInterfaces.length); - for (int i = 0; i < superInterfaces.length; i++) { - UnresolvedType ibound = superInterfaces[i]; + for (UnresolvedType ibound : superInterfaces) { ibound.write(s); } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariableReferenceType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariableReferenceType.java index 1e867ab5e..43c3b5cdd 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariableReferenceType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeVariableReferenceType.java @@ -100,11 +100,11 @@ public class TypeVariableReferenceType extends ReferenceType implements TypeVari typeVariable.resolve(world); ResolvedType annotationType = ResolvedType.ANNOTATION.resolve(world); UnresolvedType[] ifBounds = typeVariable.getSuperInterfaces();// AdditionalBounds(); - for (int i = 0; i < ifBounds.length; i++) { - if (((ReferenceType) ifBounds[i]).isAnnotation()) { + for (UnresolvedType ifBound : ifBounds) { + if (((ReferenceType) ifBound).isAnnotation()) { return true; } - if (ifBounds[i].equals(annotationType)) { + if (ifBound.equals(annotationType)) { return true; // annotation itself does not have the annotation flag set in Java! } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java index 0be8e3900..19f1ca5ce 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java @@ -380,7 +380,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { * @return a type object represnting that JVM bytecode signature. */ public static UnresolvedType forSignature(String signature) { - assert !(signature.startsWith("L") && signature.indexOf("<") != -1); + assert !(signature.startsWith("L") && signature.contains("<")); switch (signature.charAt(0)) { case 'B': return UnresolvedType.BYTE; @@ -753,7 +753,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { return name.replace('.','/'); } - if (name.indexOf("<") == -1) { + if (!name.contains("<")) { // not parameterized return new StringBuilder("L").append(name.replace('.', '/')).append(';').toString(); } else { @@ -875,12 +875,11 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { if (vars == null || vars.length == 0) { return null; } - for (int i = 0; i < vars.length; i++) { - TypeVariable aVar = vars[i]; - if (aVar.getName().equals(name)) { - return aVar; - } - } + for (TypeVariable aVar : vars) { + if (aVar.getName().equals(name)) { + return aVar; + } + } return null; } @@ -904,7 +903,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { public String getClassName() { if (className == null) { String name = getName(); - if (name.indexOf("<") != -1) { + if (name.contains("<")) { name = name.substring(0, name.indexOf("<")); } int index = name.lastIndexOf('.'); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java index 8053af0c0..2ca0173be 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java @@ -25,14 +25,14 @@ public class Utils { return false; } // Go through the annotation types on the advice - for (int i = 0; i < anns.length; i++) { - if (UnresolvedType.SUPPRESS_AJ_WARNINGS.getSignature().equals(anns[i].getTypeSignature())) { + for (AnnotationAJ ann : anns) { + if (UnresolvedType.SUPPRESS_AJ_WARNINGS.getSignature().equals(ann.getTypeSignature())) { // Two possibilities: // 1. there are no values specified (i.e. @SuppressAjWarnings) // 2. there are values specified (i.e. @SuppressAjWarnings("A") or @SuppressAjWarnings({"A","B"}) - String value = anns[i].getStringFormOfValue("value"); + String value = ann.getStringFormOfValue("value"); // Slightly lazy, just doing a string indexof - if (value == null || value.indexOf(lintkey) != -1) { + if (value == null || value.contains(lintkey)) { return true; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java index 4e625d841..b2af422ff 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java @@ -991,10 +991,10 @@ public abstract class World implements Dump.INode { if (jps == null) { return; } - if (jps.indexOf("arrayconstruction") != -1) { + if (jps.contains("arrayconstruction")) { optionalJoinpoint_ArrayConstruction = true; } - if (jps.indexOf("synchronization") != -1) { + if (jps.contains("synchronization")) { optionalJoinpoint_Synchronization = true; } } @@ -1428,7 +1428,7 @@ public abstract class World implements Dump.INode { public int compareByPrecedence(ResolvedType firstAspect, ResolvedType secondAspect) { PrecedenceCacheKey key = new PrecedenceCacheKey(firstAspect, secondAspect); if (cachedResults.containsKey(key)) { - return (cachedResults.get(key)).intValue(); + return cachedResults.get(key); } else { int order = 0; DeclarePrecedence orderer = null; // Records the declare @@ -1453,7 +1453,7 @@ public abstract class World implements Dump.INode { } } } - cachedResults.put(key, new Integer(order)); + cachedResults.put(key, order); return order; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java index 0b93b48d1..2cc737347 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java @@ -42,8 +42,8 @@ public class AnnotationPatternList extends PatternNode { public AnnotationPatternList(AnnotationTypePattern[] arguments) { this.typePatterns = arguments; - for (int i = 0; i < arguments.length; i++) { - if (arguments[i] == AnnotationTypePattern.ELLIPSIS) { + for (AnnotationTypePattern argument : arguments) { + if (argument == AnnotationTypePattern.ELLIPSIS) { ellipsisCount++; } } @@ -68,8 +68,8 @@ public class AnnotationPatternList extends PatternNode { } public void resolve(World inWorld) { - for (int i = 0; i < typePatterns.length; i++) { - typePatterns[i].resolve(inWorld); + for (AnnotationTypePattern typePattern : typePatterns) { + typePattern.resolve(inWorld); } } @@ -85,11 +85,11 @@ public class AnnotationPatternList extends PatternNode { // now work through the args and the patterns, skipping at ellipsis FuzzyBoolean ret = FuzzyBoolean.YES; int argsIndex = 0; - for (int i = 0; i < typePatterns.length; i++) { - if (typePatterns[i] == AnnotationTypePattern.ELLIPSIS) { + for (AnnotationTypePattern typePattern : typePatterns) { + if (typePattern == AnnotationTypePattern.ELLIPSIS) { // match ellipsisMatchCount args argsIndex += numArgsMatchedByEllipsis; - } else if (typePatterns[i] == AnnotationTypePattern.ANY) { + } else if (typePattern == AnnotationTypePattern.ANY) { argsIndex++; } else { // match the argument type at argsIndex with the ExactAnnotationTypePattern @@ -97,7 +97,7 @@ public class AnnotationPatternList extends PatternNode { if (someArgs[argsIndex].isPrimitiveType()) { return FuzzyBoolean.NO; // can never match } - ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern) typePatterns[i]; + ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern) typePattern; FuzzyBoolean matches = ap.matchesRuntimeType(someArgs[argsIndex]); if (matches == FuzzyBoolean.NO) { return FuzzyBoolean.MAYBE; // could still match at runtime @@ -175,8 +175,8 @@ public class AnnotationPatternList extends PatternNode { public int hashCode() { int result = 41; - for (int i = 0, len = typePatterns.length; i < len; i++) { - result = 37 * result + typePatterns[i].hashCode(); + for (AnnotationTypePattern typePattern : typePatterns) { + result = 37 * result + typePattern.hashCode(); } return result; } @@ -194,8 +194,8 @@ public class AnnotationPatternList extends PatternNode { public void write(CompressingDataOutputStream s) throws IOException { s.writeShort(typePatterns.length); - for (int i = 0; i < typePatterns.length; i++) { - typePatterns[i].write(s); + for (AnnotationTypePattern typePattern : typePatterns) { + typePattern.write(s); } writeLocation(s); } @@ -206,8 +206,8 @@ public class AnnotationPatternList extends PatternNode { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - for (int i = 0; i < typePatterns.length; i++) { - typePatterns[i].traverse(visitor, ret); + for (AnnotationTypePattern typePattern : typePatterns) { + typePattern.traverse(visitor, ret); } return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java index e829d3772..2f70523cd 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java @@ -141,8 +141,8 @@ public class AnnotationPointcut extends NameBindingPointcut { if (kind == Shadow.FieldGet || kind == Shadow.FieldSet) { // FIXME asc should include supers with getInterTypeMungersIncludingSupers ? List mungers = rMember.getDeclaringType().resolve(shadow.getIWorld()).getInterTypeMungers(); - for (Iterator iter = mungers.iterator(); iter.hasNext();) { - ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) iter.next(); + for (Object munger : mungers) { + ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) munger; if (typeMunger.getMunger() instanceof NewFieldTypeMunger) { ResolvedMember fakerm = typeMunger.getSignature(); if (fakerm.equals(member)) { @@ -162,8 +162,7 @@ public class AnnotationPointcut extends NameBindingPointcut { private ResolvedMember findMethod(ResolvedType aspectType, ResolvedMember ajcMethod) { ResolvedMember decMethods[] = aspectType.getDeclaredMethods(); - for (int i = 0; i < decMethods.length; i++) { - ResolvedMember member = decMethods[i]; + for (ResolvedMember member : decMethods) { if (member.equals(ajcMethod)) { return member; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java index db612b8cd..f7351b5d7 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java @@ -182,9 +182,9 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut { public List<BindingPattern> getBindingAnnotationTypePatterns() { List<BindingPattern> l = new ArrayList<BindingPattern>(); AnnotationTypePattern[] pats = arguments.getAnnotationPatterns(); - for (int i = 0; i < pats.length; i++) { - if (pats[i] instanceof BindingAnnotationTypePattern) { - l.add((BindingPattern)pats[i]); + for (AnnotationTypePattern pat : pats) { + if (pat instanceof BindingAnnotationTypePattern) { + l.add((BindingPattern) pat); } } return l; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsPointcut.java index 56b1a4dc5..98c78d54d 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -89,8 +89,8 @@ public class ArgsPointcut extends NameBindingPointcut { // want to ignore. if (shadow.getKind() == Shadow.AdviceExecution) { int numExtraArgs = 0; - for (int i = 0; i < argumentsToMatchAgainst.length; i++) { - String argumentSignature = argumentsToMatchAgainst[i].getSignature(); + for (ResolvedType resolvedType : argumentsToMatchAgainst) { + String argumentSignature = resolvedType.getSignature(); if (argumentSignature.startsWith(ASPECTJ_JP_SIGNATURE_PREFIX) || argumentSignature.startsWith(ASPECTJ_SYNTHETIC_SIGNATURE_PREFIX)) { numExtraArgs++; @@ -124,9 +124,9 @@ public class ArgsPointcut extends NameBindingPointcut { public List<BindingTypePattern> getBindingTypePatterns() { List<BindingTypePattern> l = new ArrayList<BindingTypePattern>(); TypePattern[] pats = arguments.getTypePatterns(); - for (int i = 0; i < pats.length; i++) { - if (pats[i] instanceof BindingTypePattern) { - l.add((BindingTypePattern)pats[i]); + for (TypePattern pat : pats) { + if (pat instanceof BindingTypePattern) { + l.add((BindingTypePattern) pat); } } return l; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/Bindings.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/Bindings.java index 4853dd049..3b095c467 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/Bindings.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/Bindings.java @@ -97,9 +97,9 @@ public class Bindings { public UnresolvedType[] getUsedFormalTypes() { UnresolvedType[] ret = new UnresolvedType[bindings.length]; int index = 0; - for (int i = 0, len = bindings.length; i < len; i++) { - if (bindings[i] != null) { - ret[index++] = ((BindingTypePattern) bindings[i]).getExactType(); + for (BindingPattern binding : bindings) { + if (binding != null) { + ret[index++] = ((BindingTypePattern) binding).getExactType(); } } UnresolvedType[] newRet = new UnresolvedType[index]; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java index 627b622eb..bef0d145c 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java @@ -106,8 +106,7 @@ public class ExactAnnotationFieldTypePattern extends ExactAnnotationTypePattern ResolvedMember[] annotationFields = theAnnotationType.getDeclaredMethods(); field = null; boolean looksAmbiguous = false; - for (int i = 0; i < annotationFields.length; i++) { - ResolvedMember resolvedMember = annotationFields[i]; + for (ResolvedMember resolvedMember : annotationFields) { if (resolvedMember.getReturnType().equals(formalBinding.getType())) { if (field != null) { boolean haveProblem = true; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java index b51d72df9..8105a4f1d 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java @@ -220,11 +220,11 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern { if (parameterAnnotations == null) { return FuzzyBoolean.NO; } - for (int i = 0; i < parameterAnnotations.length; i++) { - if (annotationType.equals(parameterAnnotations[i])) { + for (ResolvedType parameterAnnotation : parameterAnnotations) { + if (annotationType.equals(parameterAnnotation)) { // Are we also matching annotation values? if (annotationValues != null) { - parameterAnnotations[i] + parameterAnnotation .getWorld() .getMessageHandler() .handleMessage( @@ -383,8 +383,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern { } else { s.writeInt(annotationValues.size()); Set<String> key = annotationValues.keySet(); - for (Iterator<String> keys = key.iterator(); keys.hasNext();) { - String k = keys.next(); + for (String k : key) { s.writeUTF(k); s.writeUTF(annotationValues.get(k)); } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExposedState.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExposedState.java index 2a9807118..8ff7849af 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExposedState.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExposedState.java @@ -53,8 +53,8 @@ public class ExposedState { } public boolean isFullySetUp() { - for (int i = 0; i < vars.length; i++) { - if (vars[i] == null) + for (Var var : vars) { + if (var == null) return false; } return true; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/HasMemberTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/HasMemberTypePattern.java index 2b1f28fd4..c84cf3eee 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/HasMemberTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/HasMemberTypePattern.java @@ -104,8 +104,7 @@ public class HasMemberTypePattern extends TypePattern { } // try itds before we give up (this doesnt find annotations - the signature returned may not include them) List<ConcreteTypeMunger> mungers = type.getInterTypeMungersIncludingSupers(); - for (Iterator<ConcreteTypeMunger> iter = mungers.iterator(); iter.hasNext();) { - ConcreteTypeMunger munger = iter.next(); + for (ConcreteTypeMunger munger : mungers) { Member member = munger.getSignature(); if (signaturePattern.matches(member, type.getWorld(), false)) { if (!Modifier.isPublic(member.getModifiers())) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ModifiersPattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ModifiersPattern.java index 6c1d0557e..d4b747af3 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ModifiersPattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ModifiersPattern.java @@ -33,10 +33,11 @@ public class ModifiersPattern extends PatternNode { int flag = 1; while (flag <= Modifier.STRICT) { String flagName = Modifier.toString(flag); - modifierFlags.put(flagName, new Integer(flag)); + modifierFlags.put(flagName, flag); flag = flag << 1; } - modifierFlags.put("synthetic", new Integer(0x1000 /* Modifier.SYNTHETIC */)); + /* Modifier.SYNTHETIC */ + modifierFlags.put("synthetic", 0x1000); } public ModifiersPattern(int requiredModifiers, int forbiddenModifiers) { @@ -96,7 +97,7 @@ public class ModifiersPattern extends PatternNode { if (flag == null) { return -1; } - return flag.intValue(); + return flag; } public Object accept(PatternNodeVisitor visitor, Object data) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NamePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NamePattern.java index 561b99197..52331d13e 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NamePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NamePattern.java @@ -32,8 +32,8 @@ public class NamePattern extends PatternNode { public NamePattern(char[] pattern) { this.pattern = pattern; - for (int i = 0, len = pattern.length; i < len; i++) { - if (pattern[i] == '*') { + for (char c : pattern) { + if (c == '*') { starCount++; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java index 81ff33bab..72e552ab4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java @@ -330,8 +330,7 @@ public class PointcutRewriter { SortedSet<Pointcut> nodes = new TreeSet<Pointcut>(new PointcutEvaluationExpenseComparator()); collectAndNodes(apc, nodes); // look for A and !A, or IfFalse - for (Iterator<Pointcut> iter = nodes.iterator(); iter.hasNext();) { - Pointcut element = iter.next(); + for (Pointcut element : nodes) { if (element instanceof NotPointcut) { Pointcut body = ((NotPointcut) element).getNegatedPointcut(); if (nodes.contains(body)) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java index 365b5b7a7..4541d1579 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java @@ -140,8 +140,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { patternNode.traverse(visitor, null); if (visitor.containedIncorrectTargetKind()) { Set<ExactAnnotationTypePattern> keys = visitor.getIncorrectTargetKinds().keySet(); - for (Iterator<ExactAnnotationTypePattern> iter = keys.iterator(); iter.hasNext();) { - PatternNode node = iter.next(); + for (PatternNode node : keys) { AnnotationTargetKind[] targetKinds = visitor.getIncorrectTargetKinds().get(node); reportUnmatchedTargetKindMessage(targetKinds, node, scope, false); } @@ -208,12 +207,12 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { return data; } List<AnnotationTargetKind> incorrectTargets = new ArrayList<AnnotationTargetKind>(); - for (int i = 0; i < targetKinds.length; i++) { - if (targetKinds[i].getName().equals(kind.getName()) - || (targetKinds[i].getName().equals("PARAMETER") && node.isForParameterAnnotationMatch())) { + for (AnnotationTargetKind targetKind : targetKinds) { + if (targetKind.getName().equals(kind.getName()) + || (targetKind.getName().equals("PARAMETER") && node.isForParameterAnnotationMatch())) { return data; } - incorrectTargets.add(targetKinds[i]); + incorrectTargets.add(targetKind); } if (incorrectTargets.isEmpty()) { return data; @@ -227,8 +226,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { } // exception here is if parameter annotations are allowed if (parameterTargettingAnnotationsAllowed) { - for (int i = 0; i < targetKinds.length; i++) { - AnnotationTargetKind annotationTargetKind = targetKinds[i]; + for (AnnotationTargetKind annotationTargetKind : targetKinds) { if (annotationTargetKind.getName().equals("PARAMETER") && node.isForParameterAnnotationMatch()) { return data; } @@ -724,8 +722,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { private ResolvedMember findMethod(ResolvedType aspectType, ResolvedMember ajcMethod) { ResolvedMember decMethods[] = aspectType.getDeclaredMethods(); - for (int i = 0; i < decMethods.length; i++) { - ResolvedMember member = decMethods[i]; + for (ResolvedMember member : decMethods) { if (member.equals(ajcMethod)) { return member; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SimpleScope.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SimpleScope.java index 119103d84..1dfe1f6ec 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SimpleScope.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SimpleScope.java @@ -40,8 +40,7 @@ public class SimpleScope implements IScope { } public UnresolvedType lookupType(String name, IHasPosition location) { - for (int i = 0; i < importedNames.length; i++) { - String importedName = importedNames[i]; + for (String importedName : importedNames) { // make sure we're matching against the type name rather than part of it // if (importedName.endsWith("." + name)) { if (importedName.endsWith(name)) { @@ -104,9 +103,9 @@ public class SimpleScope implements IScope { } public FormalBinding lookupFormal(String name) { - for (int i = 0, len = bindings.length; i < len; i++) { - if (bindings[i].getName().equals(name)) { - return bindings[i]; + for (FormalBinding binding : bindings) { + if (binding.getName().equals(name)) { + return binding; } } return null; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java index da9d6e15a..040d6dbe2 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java @@ -51,8 +51,8 @@ public class TypePatternList extends PatternNode { public TypePatternList(TypePattern[] arguments) { this.typePatterns = arguments; - for (int i = 0; i < arguments.length; i++) { - if (arguments[i] == TypePattern.ELLIPSIS) { + for (TypePattern argument : arguments) { + if (argument == TypePattern.ELLIPSIS) { ellipsisCount++; } } @@ -452,8 +452,7 @@ public class TypePatternList extends PatternNode { } public void postRead(ResolvedType enclosingType) { - for (int i = 0; i < typePatterns.length; i++) { - TypePattern p = typePatterns[i]; + for (TypePattern p : typePatterns) { p.postRead(enclosingType); } } @@ -479,8 +478,8 @@ public class TypePatternList extends PatternNode { @Override public int hashCode() { int result = 41; - for (int i = 0, len = typePatterns.length; i < len; i++) { - result = 37 * result + typePatterns[i].hashCode(); + for (TypePattern typePattern : typePatterns) { + result = 37 * result + typePattern.hashCode(); } return result; } @@ -521,8 +520,8 @@ public class TypePatternList extends PatternNode { @Override public void write(CompressingDataOutputStream s) throws IOException { s.writeShort(typePatterns.length); - for (int i = 0; i < typePatterns.length; i++) { - typePatterns[i].write(s); + for (TypePattern typePattern : typePatterns) { + typePattern.write(s); } // writeLocation(s); } @@ -533,8 +532,8 @@ public class TypePatternList extends PatternNode { public List<UnresolvedType> getExactTypes() { List<UnresolvedType> ret = new ArrayList<UnresolvedType>(); - for (int i = 0; i < typePatterns.length; i++) { - UnresolvedType t = typePatterns[i].getExactType(); + for (TypePattern typePattern : typePatterns) { + UnresolvedType t = typePattern.getExactType(); if (!ResolvedType.isMissing(t)) { ret.add(t); } @@ -550,15 +549,14 @@ public class TypePatternList extends PatternNode { @Override public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - for (int i = 0; i < typePatterns.length; i++) { - typePatterns[i].traverse(visitor, ret); + for (TypePattern typePattern : typePatterns) { + typePattern.traverse(visitor, ret); } return ret; } public boolean areAllExactWithNoSubtypesAllowed() { - for (int i = 0; i < typePatterns.length; i++) { - TypePattern array_element = typePatterns[i]; + for (TypePattern array_element : typePatterns) { if (!(array_element instanceof ExactTypePattern)) { return false; } else { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java index d4bdf2e58..8289d306e 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java @@ -37,11 +37,10 @@ public class TypePatternQuestions { } public Question anyChanges() { - for (Iterator<Map.Entry<Question,FuzzyBoolean>> i = questionsAndAnswers.entrySet().iterator(); i.hasNext(); ) { - Map.Entry<Question,FuzzyBoolean> entry = i.next(); - Question question = (Question)entry.getKey(); - FuzzyBoolean expectedAnswer = (FuzzyBoolean)entry.getValue(); - + for (Map.Entry<Question, FuzzyBoolean> entry : questionsAndAnswers.entrySet()) { + Question question = (Question) entry.getKey(); + FuzzyBoolean expectedAnswer = (FuzzyBoolean) entry.getValue(); + FuzzyBoolean currentAnswer = question.ask(); //System.out.println(question + ":" + currentAnswer); if (currentAnswer != expectedAnswer) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePattern.java index c2d4bd0ec..57377abb5 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePattern.java @@ -163,8 +163,8 @@ public class TypeVariablePattern extends PatternNode { hashCode = hashCode * 37 + lowerBound.hashCode(); } if (interfaceBounds != null) { - for (int i = 0; i < interfaceBounds.length; i++) { - hashCode = 37 * hashCode + interfaceBounds[i].hashCode(); + for (TypePattern interfaceBound : interfaceBounds) { + hashCode = 37 * hashCode + interfaceBound.hashCode(); } } return hashCode; @@ -207,8 +207,8 @@ public class TypeVariablePattern extends PatternNode { s.writeInt(0); } else { s.writeInt(interfaceBounds.length); - for (int i = 0; i < interfaceBounds.length; i++) { - interfaceBounds[i].write(s); + for (TypePattern interfaceBound : interfaceBounds) { + interfaceBound.write(s); } } s.writeBoolean(hasLowerBound()); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePatternList.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePatternList.java index 7bbe67872..85dca44b4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePatternList.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePatternList.java @@ -35,9 +35,9 @@ public class TypeVariablePatternList extends PatternNode { } public TypeVariablePattern lookupTypeVariable(String name) { - for (int i = 0; i < patterns.length; i++) { - if (patterns[i].getName().equals(name)) { - return patterns[i]; + for (TypeVariablePattern pattern : patterns) { + if (pattern.getName().equals(name)) { + return pattern; } } return null; @@ -49,8 +49,8 @@ public class TypeVariablePatternList extends PatternNode { public void write(CompressingDataOutputStream s) throws IOException { s.writeInt(patterns.length); - for (int i = 0; i < patterns.length; i++) { - patterns[i].write(s); + for (TypeVariablePattern pattern : patterns) { + pattern.write(s); } writeLocation(s); } @@ -75,8 +75,8 @@ public class TypeVariablePatternList extends PatternNode { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - for (int i = 0; i < patterns.length; i++) { - patterns[i].traverse(visitor, ret); + for (TypeVariablePattern pattern : patterns) { + pattern.traverse(visitor, ret); } return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java index 0941462d1..531b3d09f 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java @@ -93,8 +93,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { } String v = annotationValues.get(k); boolean validKey = false; - for (int i = 0; i < ms.length; i++) { - ResolvedMember resolvedMember = ms[i]; + for (ResolvedMember resolvedMember : ms) { if (resolvedMember.getName().equals(key) && resolvedMember.isAbstract()) { validKey = true; ResolvedType t = resolvedMember.getReturnType().resolve(scope.getWorld()); @@ -213,7 +212,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { break; } else { if (t.isAnnotation()) { - if (v.indexOf("(") != -1) { + if (v.contains("(")) { throw new RuntimeException( "Compiler limitation: annotation values can only currently be marker annotations (no values): " + v); @@ -239,8 +238,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { // } // replacementValues.put(k, rt.getSignature()); } else { - scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.UNSUPPORTED_ANNOTATION_VALUE_TYPE,t), getSourceLocation())); - replacementValues.put(k,""); + scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.UNSUPPORTED_ANNOTATION_VALUE_TYPE, t), getSourceLocation())); + replacementValues.put(k, ""); } } } @@ -265,8 +264,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { } if (isForParameterAnnotationMatch()) { if (parameterAnnotations != null && parameterAnnotations.length != 0) { - for (int i = 0; i < parameterAnnotations.length; i++) { - if (typePattern.matches(parameterAnnotations[i], TypePattern.STATIC).alwaysTrue()) { + for (ResolvedType parameterAnnotation : parameterAnnotations) { + if (typePattern.matches(parameterAnnotation, TypePattern.STATIC).alwaysTrue()) { return FuzzyBoolean.YES; } } @@ -276,8 +275,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { // matched by the typePattern. ResolvedType[] annTypes = annotated.getAnnotationTypes(); if (annTypes != null && annTypes.length != 0) { - for (int i = 0; i < annTypes.length; i++) { - if (typePattern.matches(annTypes[i], TypePattern.STATIC).alwaysTrue()) { + for (ResolvedType annType : annTypes) { + if (typePattern.matches(annType, TypePattern.STATIC).alwaysTrue()) { return FuzzyBoolean.YES; } } @@ -298,7 +297,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { if (typePattern instanceof WildTypePattern && (annotationValues == null || annotationValues.isEmpty())) { WildTypePattern wildTypePattern = (WildTypePattern) typePattern; String fullyQualifiedName = wildTypePattern.maybeGetCleanName(); - if (fullyQualifiedName != null && fullyQualifiedName.indexOf(".") != -1) { + if (fullyQualifiedName != null && fullyQualifiedName.contains(".")) { ResolvedType resolvedType = world.resolve(UnresolvedType.forName(fullyQualifiedName)); if (resolvedType != null && !resolvedType.isMissing()) { typePattern = new ExactTypePattern(resolvedType, false, false); @@ -368,8 +367,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { } else { s.writeInt(annotationValues.size()); Set<String> key = annotationValues.keySet(); - for (Iterator<String> keys = key.iterator(); keys.hasNext();) { - String k = keys.next(); + for (String k : key) { s.writeUTF(k); s.writeUTF(annotationValues.get(k)); } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java index 9081c5c02..c766d30ba 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java @@ -101,8 +101,8 @@ public class WildTypePattern extends TypePattern { this.namePatterns = namePatterns; this.dim = dim; ellipsisCount = 0; - for (int i = 0; i < namePatterns.length; i++) { - if (namePatterns[i] == NamePattern.ELLIPSIS) { + for (NamePattern namePattern : namePatterns) { + if (namePattern == NamePattern.ELLIPSIS) { ellipsisCount++; } } @@ -341,14 +341,13 @@ public class WildTypePattern extends TypePattern { // we've already ruled out "*", and no other name pattern should match an anonymous type return false; } - for (int i = 0, len = knownMatches.length; i < len; i++) { - if (knownMatches[i].equals(targetTypeName)) { + for (String knownMatch : knownMatches) { + if (knownMatch.equals(targetTypeName)) { return true; } } } else { - for (int i = 0, len = knownMatches.length; i < len; i++) { - String knownMatch = knownMatches[i]; + for (String knownMatch : knownMatches) { // String knownPrefix = knownMatches[i] + "$"; // if (targetTypeName.startsWith(knownPrefix)) { if (targetTypeName.startsWith(knownMatch) && targetTypeName.length() > knownMatch.length() @@ -363,8 +362,7 @@ public class WildTypePattern extends TypePattern { // if any prefixes match, strip the prefix and check that the rest matches // assumes that prefixes have a dot at the end - for (int i = 0, len = importedPrefixes.length; i < len; i++) { - String prefix = importedPrefixes[i]; + for (String prefix : importedPrefixes) { // System.err.println("prefix match? " + prefix + " to " + targetTypeName); if (targetTypeName.startsWith(prefix)) { @@ -965,8 +963,8 @@ public class WildTypePattern extends TypePattern { canCreateExactTypePattern = false; } if (additionalInterfaceBounds != null) { - for (int i = 0; i < additionalInterfaceBounds.length; i++) { - if (ResolvedType.isMissing(additionalInterfaceBounds[i].getExactType())) { + for (TypePattern additionalInterfaceBound : additionalInterfaceBounds) { + if (ResolvedType.isMissing(additionalInterfaceBound.getExactType())) { canCreateExactTypePattern = false; } } @@ -1012,9 +1010,9 @@ public class WildTypePattern extends TypePattern { int minRequiredTypeParameters = typeParameters.size(); boolean foundEllipsis = false; TypePattern[] typeParamPatterns = typeParameters.getTypePatterns(); - for (int i = 0; i < typeParamPatterns.length; i++) { - if (typeParamPatterns[i] instanceof WildTypePattern) { - WildTypePattern wtp = (WildTypePattern) typeParamPatterns[i]; + for (TypePattern typeParamPattern : typeParamPatterns) { + if (typeParamPattern instanceof WildTypePattern) { + WildTypePattern wtp = (WildTypePattern) typeParamPattern; if (wtp.ellipsisCount > 0) { foundEllipsis = true; minRequiredTypeParameters--; @@ -1025,7 +1023,7 @@ public class WildTypePattern extends TypePattern { if ((tvs.length < minRequiredTypeParameters) || (!foundEllipsis && minRequiredTypeParameters != tvs.length)) { // issue message "does not match because wrong no of type params" String msg = WeaverMessages.format(WeaverMessages.INCORRECT_NUMBER_OF_TYPE_ARGUMENTS, genericType.getName(), - new Integer(tvs.length)); + tvs.length); if (requireExactType) { scope.message(MessageUtil.error(msg, getSourceLocation())); } else { @@ -1094,7 +1092,7 @@ public class WildTypePattern extends TypePattern { parameterName = ((TypeVariableReference) ut).getTypeVariable().getDisplayName(); } String msg = WeaverMessages.format(WeaverMessages.VIOLATES_TYPE_VARIABLE_BOUNDS, parameterName, - new Integer(i + 1), tvs[i].getDisplayName(), genericType.getName()); + i + 1, tvs[i].getDisplayName(), genericType.getName()); if (requireExactType) { scope.message(MessageUtil.error(msg, sLoc)); } else { @@ -1160,16 +1158,16 @@ public class WildTypePattern extends TypePattern { // if (namePatterns.length != 1) return CollectionUtil.NO_STRINGS; List<String> ret = new ArrayList<String>(); - for (int i = 0, len = possibleMatches.length; i < len; i++) { - char[][] names = splitNames(possibleMatches[i], true); // ??? not most efficient + for (String possibleMatch : possibleMatches) { + char[][] names = splitNames(possibleMatch, true); // ??? not most efficient if (namePatterns[0].matches(names[names.length - 1])) { - ret.add(possibleMatches[i]); + ret.add(possibleMatch); continue; } - if (possibleMatches[i].indexOf("$") != -1) { - names = splitNames(possibleMatches[i], false); // ??? not most efficient + if (possibleMatch.contains("$")) { + names = splitNames(possibleMatch, false); // ??? not most efficient if (namePatterns[0].matches(names[names.length - 1])) { - ret.add(possibleMatches[i]); + ret.add(possibleMatch); } } } @@ -1282,8 +1280,8 @@ public class WildTypePattern extends TypePattern { @Override public int hashCode() { int result = 17; - for (int i = 0, len = namePatterns.length; i < len; i++) { - result = 37 * result + namePatterns[i].hashCode(); + for (NamePattern namePattern : namePatterns) { + result = 37 * result + namePattern.hashCode(); } result = 37 * result + annotationPattern.hashCode(); if (upperBound != null) { @@ -1302,8 +1300,8 @@ public class WildTypePattern extends TypePattern { s.writeByte(TypePattern.WILD); s.writeByte(VERSION); s.writeShort(namePatterns.length); - for (int i = 0; i < namePatterns.length; i++) { - namePatterns[i].write(s); + for (NamePattern namePattern : namePatterns) { + namePattern.write(s); } s.writeBoolean(includeSubtypes); s.writeInt(dim); @@ -1327,8 +1325,8 @@ public class WildTypePattern extends TypePattern { } s.writeInt(additionalInterfaceBounds == null ? 0 : additionalInterfaceBounds.length); if (additionalInterfaceBounds != null) { - for (int i = 0; i < additionalInterfaceBounds.length; i++) { - additionalInterfaceBounds[i].write(s); + for (TypePattern additionalInterfaceBound : additionalInterfaceBounds) { + additionalInterfaceBound.write(s); } } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java index e549325af..afc14188d 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java @@ -149,8 +149,8 @@ public class StandardPointcutParser { */ private StandardPointcutParser(Set/* <PointcutPrimitives> */supportedPointcutKinds, World world) { supportedPrimitives = supportedPointcutKinds; - for (Iterator iter = supportedPointcutKinds.iterator(); iter.hasNext();) { - PointcutPrimitive element = (PointcutPrimitive) iter.next(); + for (Object supportedPointcutKind : supportedPointcutKinds) { + PointcutPrimitive element = (PointcutPrimitive) supportedPointcutKind; if ((element == PointcutPrimitive.IF) || (element == PointcutPrimitive.CFLOW) || (element == PointcutPrimitive.CFLOW_BELOW)) { throw new UnsupportedOperationException("Cannot handle if, cflow, and cflowbelow primitives"); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java index 6d819de50..e9b42fb83 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java @@ -32,7 +32,7 @@ public abstract class TraceFactory { protected static boolean getBoolean(String name, boolean def) { String defaultValue = String.valueOf(def); String value = System.getProperty(name,defaultValue); - return Boolean.valueOf(value).booleanValue(); + return Boolean.valueOf(value); } static { diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonAdvancedPointcutExpressionTests.java b/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonAdvancedPointcutExpressionTests.java index 532588363..4175425ef 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonAdvancedPointcutExpressionTests.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonAdvancedPointcutExpressionTests.java @@ -655,10 +655,10 @@ public abstract class CommonAdvancedPointcutExpressionTests extends TestCase { private ResolvedMember getMethod(ResolvedType type, String methodName, String methodSignature) { ResolvedMember[] methods = type.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName) - && (methodSignature == null || methodSignature.equals(methods[i].getSignature()))) { - return methods[i]; + for (ResolvedMember method : methods) { + if (method.getName().equals(methodName) + && (methodSignature == null || methodSignature.equals(method.getSignature()))) { + return method; } } return null; diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java b/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java index 8fccfbf99..02ad20f1f 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java @@ -738,11 +738,11 @@ public abstract class CommonPointcutExpressionTests extends TestCase { private ResolvedMember getMethod(ResolvedType type, String methodName, String methodSignature) { ResolvedMember[] methods = type.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - System.out.println(methods[i].getName() + methods[i].getSignature()); - if (methods[i].getName().equals(methodName) - && (methodSignature == null || methodSignature.equals(methods[i].getSignature()))) { - return methods[i]; + for (ResolvedMember method : methods) { + System.out.println(method.getName() + method.getSignature()); + if (method.getName().equals(methodName) + && (methodSignature == null || methodSignature.equals(method.getSignature()))) { + return method; } } return null; diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java index ff6c56a34..8998904a6 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java @@ -49,8 +49,7 @@ public abstract class CommonWorldTests extends TestCase { public void testPrimitiveTypes() { ResolvedType[] primitives = world.resolve(primitiveTypes); - for (int i = 0, len = primitives.length; i < len; i++) { - ResolvedType ty = primitives[i]; + for (ResolvedType ty : primitives) { modifiersTest(ty, Modifier.PUBLIC | Modifier.FINAL); fieldsTest(ty, ResolvedMember.NONE); methodsTest(ty, ResolvedMember.NONE); @@ -60,8 +59,7 @@ public abstract class CommonWorldTests extends TestCase { isInterfaceTest(ty, false); isClassTest(ty, false); isAspectTest(ty, false); - for (int j = 0; j < len; j++) { - ResolvedType ty1 = primitives[j]; + for (ResolvedType ty1 : primitives) { if (ty.equals(ty1)) { isCoerceableFromTest(ty, ty1, true); } else if (ty.equals(UnresolvedType.BOOLEAN) || ty1.equals(UnresolvedType.BOOLEAN) @@ -75,15 +73,15 @@ public abstract class CommonWorldTests extends TestCase { // Result of this depends on whether autoboxing is supported // isCoerceableFromTest(ty, UnresolvedType.OBJECT, getSupportsAutoboxing()); - primAssignTest("B", new String[] {}); - primAssignTest("S", new String[] { "B" }); - primAssignTest("C", new String[] { "B" }); - primAssignTest("I", new String[] { "B", "S", "C" }); - primAssignTest("J", new String[] { "B", "S", "C", "I" }); - primAssignTest("F", new String[] { "B", "S", "C", "I", "J" }); - primAssignTest("D", new String[] { "B", "S", "C", "I", "J", "F" }); - primAssignTest("Z", new String[] {}); - primAssignTest("V", new String[] {}); + primAssignTest("B", new String[]{}); + primAssignTest("S", new String[]{"B"}); + primAssignTest("C", new String[]{"B"}); + primAssignTest("I", new String[]{"B", "S", "C"}); + primAssignTest("J", new String[]{"B", "S", "C", "I"}); + primAssignTest("F", new String[]{"B", "S", "C", "I", "J"}); + primAssignTest("D", new String[]{"B", "S", "C", "I", "J", "F"}); + primAssignTest("Z", new String[]{}); + primAssignTest("V", new String[]{}); } } @@ -110,8 +108,7 @@ public abstract class CommonWorldTests extends TestCase { public void testPrimitiveArrays() { ResolvedType[] primitives = world.resolve(primitiveTypes); - for (int i = 0, len = primitives.length; i < len; i++) { - ResolvedType ty = primitives[i]; + for (ResolvedType ty : primitives) { UnresolvedType tx = UnresolvedType.forSignature("[" + ty.getSignature()); ResolvedType aty = world.resolve(tx, true); assertTrue("Couldnt find type " + tx, !aty.isMissing()); @@ -120,16 +117,15 @@ public abstract class CommonWorldTests extends TestCase { methodsTest(aty, ResolvedMember.NONE); interfaceTest( aty, - new ResolvedType[] { world.getCoreType(UnresolvedType.CLONEABLE), - world.getCoreType(UnresolvedType.SERIALIZABLE) }); + new ResolvedType[]{world.getCoreType(UnresolvedType.CLONEABLE), + world.getCoreType(UnresolvedType.SERIALIZABLE)}); superclassTest(aty, UnresolvedType.OBJECT); pointcutsTest(aty, ResolvedMember.NONE); isInterfaceTest(aty, false); isClassTest(aty, false); isAspectTest(aty, false); - for (int j = 0; j < len; j++) { - ResolvedType ty1 = primitives[j]; + for (ResolvedType ty1 : primitives) { isCoerceableFromTest(aty, ty1, false); tx = UnresolvedType.forSignature("[" + ty1.getSignature()); ResolvedType aty1 = getWorld().resolve(tx, true); @@ -144,8 +140,7 @@ public abstract class CommonWorldTests extends TestCase { } } // double dimension arrays - for (int i = 0, len = primitives.length; i < len; i++) { - ResolvedType ty = primitives[i]; + for (ResolvedType ty : primitives) { UnresolvedType tx = UnresolvedType.forSignature("[[" + ty.getSignature()); ResolvedType aty = world.resolve(tx, true); assertTrue("Couldnt find type " + tx, !aty.isMissing()); @@ -154,16 +149,15 @@ public abstract class CommonWorldTests extends TestCase { methodsTest(aty, ResolvedMember.NONE); interfaceTest( aty, - new ResolvedType[] { world.getCoreType(UnresolvedType.CLONEABLE), - world.getCoreType(UnresolvedType.SERIALIZABLE) }); + new ResolvedType[]{world.getCoreType(UnresolvedType.CLONEABLE), + world.getCoreType(UnresolvedType.SERIALIZABLE)}); superclassTest(aty, UnresolvedType.OBJECT); pointcutsTest(aty, ResolvedMember.NONE); isInterfaceTest(aty, false); isClassTest(aty, false); isAspectTest(aty, false); - for (int j = 0; j < len; j++) { - ResolvedType ty1 = primitives[j]; + for (ResolvedType ty1 : primitives) { isCoerceableFromTest(aty, ty1, false); tx = UnresolvedType.forSignature("[[" + ty1.getSignature()); ResolvedType aty1 = getWorld().resolve(tx, true); @@ -201,15 +195,15 @@ public abstract class CommonWorldTests extends TestCase { protected void interfaceTest(ResolvedType type, ResolvedType[] expectedInterfaces) { ResolvedType[] interfaces = type.getDeclaredInterfaces(); - for (int i = 0; i < expectedInterfaces.length; i++) { + for (ResolvedType expectedInterface : expectedInterfaces) { boolean wasMissing = true; - for (int j = 0; j < interfaces.length; j++) { - if (interfaces[j].getSignature().equals(expectedInterfaces[i].getSignature())) { + for (ResolvedType anInterface : interfaces) { + if (anInterface.getSignature().equals(expectedInterface.getSignature())) { wasMissing = false; } } if (wasMissing) { - fail("Expected declared interface " + expectedInterfaces[i] + " but it wasn't found in " + fail("Expected declared interface " + expectedInterface + " but it wasn't found in " + Arrays.asList(interfaces)); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java index 705674cb3..b60cad835 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java @@ -116,15 +116,15 @@ public class ArgsTestCase extends TestCase { Method oneIntegerM = A.class.getMethod("anInteger", new Class[] { Integer.class }); if (LangUtil.is15VMOrGreater()) { - checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] { new Integer(5) }); - checkMatches(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] { new Integer(5) }); - checkMatches(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] { new Integer(5) }); - checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] { new Integer(5) }); + checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); + checkMatches(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); + checkMatches(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); + checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); } else { - checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] { new Integer(5) }); - checkNoMatch(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] { new Integer(5) }); - checkNoMatch(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] { new Integer(5) }); - checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] { new Integer(5) }); + checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); + checkNoMatch(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); + checkNoMatch(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); + checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); } } catch (Exception ex) { diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java index 7303191dd..132512e5a 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java @@ -102,7 +102,7 @@ public class BindingTestCase extends PatternsTestCase { // System.out.println("expected exception: " + re); return; } catch (Throwable t) { - assertTrue(prefix, t.getMessage().indexOf(prefix) != -1); + assertTrue(prefix, t.getMessage().contains(prefix)); return; } assertTrue("should have failed", false); diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/DumpPointcutVisitor.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/DumpPointcutVisitor.java index 665f4bdda..2b0e01888 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/DumpPointcutVisitor.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/DumpPointcutVisitor.java @@ -549,8 +549,8 @@ public class DumpPointcutVisitor implements PatternNodeVisitor { "(if(true) && set(int BaseApp.i))" }; - for (int i = 0; i < s.length; i++) { - check(s[i]); + for (String value : s) { + check(value); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java index 265ee4b0a..8c8a89035 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java @@ -64,9 +64,9 @@ public class ModifiersPatternTestCase extends PatternsTestCase { } private void checkMatch(ModifiersPattern p, int[] matches, boolean shouldMatch) { - for (int i = 0; i < matches.length; i++) { - boolean result = p.matches(matches[i]); - String msg = "matches " + p + " to " + Modifier.toString(matches[i]) + " expected "; + for (int match : matches) { + boolean result = p.matches(match); + String msg = "matches " + p + " to " + Modifier.toString(match) + " expected "; if (shouldMatch) { assertTrue(msg + shouldMatch, result); } else { @@ -78,8 +78,8 @@ public class ModifiersPatternTestCase extends PatternsTestCase { public void testSerialization() throws IOException { String[] patterns = new String[] { "", "!public", "public", "public static", "private !static !strictfp", }; - for (int i = 0, len = patterns.length; i < len; i++) { - checkSerialization(patterns[i]); + for (String pattern : patterns) { + checkSerialization(pattern); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternParserTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternParserTestCase.java index fe3b0f2d4..f1bec0837 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternParserTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternParserTestCase.java @@ -59,8 +59,7 @@ public class NamePatternParserTestCase extends TestCase { * @param b */ private void checkMatch(String[] patterns) { - for (int i = 0, len = patterns.length; i < len; i++) { - String pattern = patterns[i]; + for (String pattern : patterns) { ITokenSource tokenSource = BasicTokenSource.makeTokenSource( pattern, null); NamePattern p1 = new PatternParser(tokenSource).parseNamePattern(); diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternTestCase.java index e1876cc3b..d26395038 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/NamePatternTestCase.java @@ -64,8 +64,8 @@ public class NamePatternTestCase extends TestCase { * @param b */ private void checkMatch(String string, String[] patterns, boolean shouldMatch) { - for (int i = 0, len = patterns.length; i < len; i++) { - NamePattern p = new NamePattern(patterns[i]); + for (String pattern : patterns) { + NamePattern p = new NamePattern(pattern); checkMatch(string, p, shouldMatch); } } @@ -82,8 +82,8 @@ public class NamePatternTestCase extends TestCase { } private void checkSerialization(String[] patterns) throws IOException { - for (int i = 0, len = patterns.length; i < len; i++) { - NamePattern p = new NamePattern(patterns[i]); + for (String pattern : patterns) { + NamePattern p = new NamePattern(pattern); checkSerialization(p); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java index d2a8fd245..f7d454f0c 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java @@ -310,8 +310,8 @@ public class PointcutRewriterTest extends TestCase { public void testKindSetOfThis() { Pointcut p = getPointcut("this(Foo)"); Set matches = Shadow.toSet(p.couldMatchKinds()); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - Shadow.Kind kind = (Shadow.Kind) iter.next(); + for (Object o : matches) { + Shadow.Kind kind = (Shadow.Kind) o; assertFalse("No kinds that don't have a this", kind.neverHasThis()); } for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { @@ -322,8 +322,8 @@ public class PointcutRewriterTest extends TestCase { // + @ p = getPointcut("@this(Foo)"); matches = Shadow.toSet(p.couldMatchKinds()); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - Shadow.Kind kind = (Shadow.Kind) iter.next(); + for (Object match : matches) { + Shadow.Kind kind = (Shadow.Kind) match; assertFalse("No kinds that don't have a this", kind.neverHasThis()); } for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { @@ -336,8 +336,8 @@ public class PointcutRewriterTest extends TestCase { public void testKindSetOfTarget() { Pointcut p = getPointcut("target(Foo)"); Set matches = Shadow.toSet(p.couldMatchKinds()); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - Shadow.Kind kind = (Shadow.Kind) iter.next(); + for (Object o : matches) { + Shadow.Kind kind = (Shadow.Kind) o; assertFalse("No kinds that don't have a target", kind.neverHasTarget()); } for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { @@ -348,8 +348,8 @@ public class PointcutRewriterTest extends TestCase { // + @ p = getPointcut("@target(Foo)"); matches = Shadow.toSet(p.couldMatchKinds()); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - Shadow.Kind kind = (Shadow.Kind) iter.next(); + for (Object match : matches) { + Shadow.Kind kind = (Shadow.Kind) match; assertFalse("No kinds that don't have a target", kind.neverHasTarget()); } for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { @@ -383,8 +383,8 @@ public class PointcutRewriterTest extends TestCase { public void testKindSetOfWithinCode() { Pointcut p = getPointcut("withincode(* foo(..))"); Set matches = Shadow.toSet(p.couldMatchKinds()); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - Shadow.Kind kind = (Shadow.Kind) iter.next(); + for (Object o : matches) { + Shadow.Kind kind = (Shadow.Kind) o; assertFalse("No kinds that are themselves enclosing", (kind.isEnclosingKind() && kind != Shadow.ConstructorExecution && kind != Shadow.Initialization)); } @@ -398,8 +398,8 @@ public class PointcutRewriterTest extends TestCase { // + @ p = getPointcut("@withincode(Foo)"); matches = Shadow.toSet(p.couldMatchKinds()); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - Shadow.Kind kind = (Shadow.Kind) iter.next(); + for (Object match : matches) { + Shadow.Kind kind = (Shadow.Kind) match; assertFalse("No kinds that are themselves enclosing", kind.isEnclosingKind()); } for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java index 52f82bfd7..756a53d7f 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java @@ -93,12 +93,12 @@ public class SignaturePatternMatchSpeedTestCase extends PatternsTestCase { public void checkMatch(SignaturePattern p, Member[] yes, Member[] no) throws IOException { p = p.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < yes.length; i++) { - checkMatch(p, yes[i], true); + for (Member value : yes) { + checkMatch(p, value, true); } - for (int i = 0; i < no.length; i++) { - checkMatch(p, no[i], false); + for (Member member : no) { + checkMatch(p, member, false); } checkSerialization(p); diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternTestCase.java index 6c6f1f985..1920646e4 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/SignaturePatternTestCase.java @@ -144,12 +144,12 @@ public class SignaturePatternTestCase extends PatternsTestCase { public void checkMatch(SignaturePattern p, Member[] yes, Member[] no) throws IOException { p = p.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < yes.length; i++) { - checkMatch(p, yes[i], true); + for (Member value : yes) { + checkMatch(p, value, true); } - for (int i = 0; i < no.length; i++) { - checkMatch(p, no[i], false); + for (Member member : no) { + checkMatch(p, member, false); } checkSerialization(p); diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternListTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternListTestCase.java index a141e2b0c..8d43fcce2 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternListTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternListTestCase.java @@ -143,8 +143,8 @@ public class TypePatternListTestCase extends PatternsTestCase { "(int, .., .., ..)", "(int, .., .., int)", "(int, .., int, ..)", "(int, .., int, int)", "(int, int, .., ..)", "(int, int, .., int)", "(int, int, int, ..)", "(int, int, int, int)" }; - for (int i = 0, len = patterns.length; i < len; i++) { - checkSerialization(patterns[i]); + for (String pattern : patterns) { + checkSerialization(pattern); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternTestCase.java index 058bd2450..5ec92e1ec 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/TypePatternTestCase.java @@ -235,8 +235,8 @@ public class TypePatternTestCase extends PatternsTestCase { String[] patterns = new String[] { "java.lang.Object", "java.lang.Object+", "java.lang.Integer", "int", "java..*", "java..util..*", "*.*.Object", "*", }; - for (int i = 0, len = patterns.length; i < len; i++) { - checkSerialization(patterns[i]); + for (String pattern : patterns) { + checkSerialization(pattern); } } |