From 72194b7982ddfa8e9864d0a9934905bb76b90f33 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 8 Aug 2020 03:06:37 +0200 Subject: 'for' loop replaceable with enhanced 'for' loop Reports for loops which iterate over collections or arrays, and can be replaced with an enhanced for loop (i.e. the foreach iteration syntax). Signed-off-by: Lars Grefer --- .../org/aspectj/weaver/AbstractAnnotationAJ.java | 5 +- .../weaver/AbstractReferenceTypeDelegate.java | 4 +- .../main/java/org/aspectj/weaver/AjAttribute.java | 6 +- .../org/aspectj/weaver/ArrayReferenceType.java | 4 +- .../org/aspectj/weaver/BoundedReferenceType.java | 8 +- .../org/aspectj/weaver/CrosscuttingMembers.java | 23 +++--- .../org/aspectj/weaver/CrosscuttingMembersSet.java | 54 ++++++------- .../src/main/java/org/aspectj/weaver/Dump.java | 10 +-- .../src/main/java/org/aspectj/weaver/Lint.java | 4 +- .../main/java/org/aspectj/weaver/MemberImpl.java | 4 +- .../aspectj/weaver/MethodDelegateTypeMunger.java | 3 +- .../java/org/aspectj/weaver/ReferenceType.java | 54 ++++++------- .../org/aspectj/weaver/ResolvedMemberImpl.java | 43 +++++------ .../main/java/org/aspectj/weaver/ResolvedType.java | 90 +++++++++++----------- .../src/main/java/org/aspectj/weaver/Shadow.java | 43 +++++------ .../java/org/aspectj/weaver/SignatureUtils.java | 8 +- .../org/aspectj/weaver/StandardAnnotation.java | 10 +-- .../main/java/org/aspectj/weaver/TypeFactory.java | 4 +- .../main/java/org/aspectj/weaver/TypeVariable.java | 33 ++++---- .../aspectj/weaver/TypeVariableReferenceType.java | 6 +- .../java/org/aspectj/weaver/UnresolvedType.java | 11 ++- .../src/main/java/org/aspectj/weaver/Utils.java | 6 +- .../weaver/patterns/AnnotationPatternList.java | 28 +++---- .../weaver/patterns/AnnotationPointcut.java | 7 +- .../weaver/patterns/ArgsAnnotationPointcut.java | 6 +- .../org/aspectj/weaver/patterns/ArgsPointcut.java | 10 +-- .../java/org/aspectj/weaver/patterns/Bindings.java | 6 +- .../patterns/ExactAnnotationFieldTypePattern.java | 3 +- .../patterns/ExactAnnotationTypePattern.java | 9 +-- .../org/aspectj/weaver/patterns/ExposedState.java | 4 +- .../weaver/patterns/HasMemberTypePattern.java | 3 +- .../org/aspectj/weaver/patterns/NamePattern.java | 4 +- .../aspectj/weaver/patterns/PointcutRewriter.java | 3 +- .../aspectj/weaver/patterns/SignaturePattern.java | 17 ++-- .../org/aspectj/weaver/patterns/SimpleScope.java | 9 +-- .../aspectj/weaver/patterns/TypePatternList.java | 26 +++---- .../weaver/patterns/TypePatternQuestions.java | 9 +-- .../weaver/patterns/TypeVariablePattern.java | 8 +- .../weaver/patterns/TypeVariablePatternList.java | 14 ++-- .../weaver/patterns/WildAnnotationTypePattern.java | 18 ++--- .../aspectj/weaver/patterns/WildTypePattern.java | 48 ++++++------ .../weaver/tools/StandardPointcutParser.java | 4 +- .../CommonAdvancedPointcutExpressionTests.java | 8 +- .../tools/CommonPointcutExpressionTests.java | 10 +-- .../java/org/aspectj/weaver/CommonWorldTests.java | 52 ++++++------- .../weaver/patterns/DumpPointcutVisitor.java | 4 +- .../weaver/patterns/ModifiersPatternTestCase.java | 10 +-- .../weaver/patterns/NamePatternParserTestCase.java | 3 +- .../weaver/patterns/NamePatternTestCase.java | 8 +- .../weaver/patterns/PointcutRewriterTest.java | 24 +++--- .../SignaturePatternMatchSpeedTestCase.java | 8 +- .../weaver/patterns/SignaturePatternTestCase.java | 8 +- .../weaver/patterns/TypePatternListTestCase.java | 4 +- .../weaver/patterns/TypePatternTestCase.java | 4 +- 54 files changed, 382 insertions(+), 430 deletions(-) (limited to 'org.aspectj.matcher') 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 7f3fb60ee..bdddec51e 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 @@ -120,8 +120,8 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele AbstractReferenceTypeDelegate outerObjectType = (AbstractReferenceTypeDelegate) outerDelegate; if (outerObjectType.isNested()) { GenericSignature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass(); - for (int i = 0; i < parentParams.length; i++) { - typeParameters.add(parentParams[i]); + for (GenericSignature.FormalTypeParameter parentParam : parentParams) { + typeParameters.add(parentParam); } } GenericSignature.ClassSignature outerSig = outerObjectType.getGenericClassTypeSignature(); 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 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 theseTypeMungers = new HashSet(); Set otherTypeMungers = new HashSet(); if (!careAboutShadowMungers) { - for (Iterator 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 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 trimmedThis = new HashSet(); - for (Iterator iterator = declareParents.iterator(); iterator.hasNext();) { - DeclareParents decp = iterator.next(); + for (DeclareParents decp : declareParents) { if (!decp.isMixin()) { trimmedThis.add(decp); } } Set trimmedOther = new HashSet(); - for (Iterator 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 iter = theseInlinedAroundMungers.iterator(); iter.hasNext();) { - Advice thisAdvice = (Advice) iter.next(); + for (ShadowMunger theseInlinedAroundMunger : theseInlinedAroundMungers) { + Advice thisAdvice = (Advice) theseInlinedAroundMunger; boolean foundIt = false; - for (Iterator 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 knownAspects = members.keySet(); Set toBeReplaced = new HashSet(); - for (Iterator 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 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 getShadowMungers() { if (shadowMungers == null) { List ret = new ArrayList(); - for (Iterator 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 getLateTypeMungers() { if (lateTypeMungers == null) { List ret = new ArrayList(); - for (Iterator 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 getDeclareSofts() { if (declareSofts == null) { Set ret = new HashSet(); - for (Iterator i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareSofts()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareSofts()); } declareSofts = new ArrayList(); declareSofts.addAll(ret); @@ -306,8 +304,8 @@ public class CrosscuttingMembersSet { public List getDeclareParents() { if (declareParents == null) { Set ret = new HashSet(); - for (Iterator i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareParents()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareParents()); } declareParents = new ArrayList(); declareParents.addAll(ret); @@ -321,8 +319,8 @@ public class CrosscuttingMembersSet { public List getDeclareAnnotationOnTypes() { if (declareAnnotationOnTypes == null) { Set ret = new LinkedHashSet(); - for (Iterator i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareAnnotationOnTypes()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareAnnotationOnTypes()); } declareAnnotationOnTypes = new ArrayList(); declareAnnotationOnTypes.addAll(ret); @@ -336,8 +334,8 @@ public class CrosscuttingMembersSet { public List getDeclareAnnotationOnFields() { if (declareAnnotationOnFields == null) { Set ret = new LinkedHashSet(); - for (Iterator i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareAnnotationOnFields()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareAnnotationOnFields()); } declareAnnotationOnFields = new ArrayList(); declareAnnotationOnFields.addAll(ret); @@ -351,8 +349,8 @@ public class CrosscuttingMembersSet { public List getDeclareAnnotationOnMethods() { if (declareAnnotationOnMethods == null) { Set ret = new LinkedHashSet(); - for (Iterator i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareAnnotationOnMethods()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareAnnotationOnMethods()); } declareAnnotationOnMethods = new ArrayList(); declareAnnotationOnMethods.addAll(ret); @@ -367,8 +365,8 @@ public class CrosscuttingMembersSet { public List getDeclareTypeEows() { if (declareTypeEows == null) { Set ret = new HashSet(); - for (Iterator i = members.values().iterator(); i.hasNext();) { - ret.addAll(i.next().getDeclareTypeErrorOrWarning()); + for (CrosscuttingMembers crosscuttingMembers : members.values()) { + ret.addAll(crosscuttingMembers.getDeclareTypeErrorOrWarning()); } declareTypeEows = new ArrayList(); declareTypeEows.addAll(ret); @@ -379,8 +377,8 @@ public class CrosscuttingMembersSet { public List getDeclareDominates() { if (declareDominates == null) { List ret = new ArrayList(); - for (Iterator 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 keys = this.members.keySet(); - for (Iterator 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 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..6e48de0d2 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 i = messageHolder.getUnmodifiableListView().iterator(); i.hasNext();) { - IMessage message = i.next(); + for (IMessage message : messageHolder.getUnmodifiableListView()) { println(message.toString()); } } else { @@ -419,8 +418,8 @@ public class Dump { return; } - for (int i = 0; i < array.length; i++) { - print.println(array[i]); + for (Object o : array) { + print.println(o); } } @@ -454,8 +453,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 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/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..90fd3ece3 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); } } @@ -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()); + for (UnresolvedType myParameterType : myParameterTypes) { + appendSigWithTypeVarBoundsRemoved(myParameterType, sig, new HashSet()); } 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..a5a5eea5d 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 i = ty.getDeclares().iterator(); i.hasNext();) { - Declare dec = i.next(); + for (Declare dec : ty.getDeclares()) { if (dec.isAdviceLike()) { if (includeAdviceLike) { ret.add(dec); @@ -1031,8 +1027,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl methods = getGenericType().getDeclaredMethods(); } Map 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 l = new ArrayList(); - 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 acc, List added, boolean isOverriding) { - for (Iterator i = added.iterator(); i.hasNext();) { - ResolvedPointcutDefinition toAdd = (ResolvedPointcutDefinition) i.next(); - for (Iterator j = acc.iterator(); j.hasNext();) { + for (ResolvedMember resolvedMember : added) { + ResolvedPointcutDefinition toAdd = (ResolvedPointcutDefinition) resolvedMember; + for (Iterator 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/Shadow.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java index cde7e5163..fc2b1d4d1 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 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; } @@ -608,13 +608,12 @@ public abstract class Shadow { } } } - for (Iterator 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/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/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 targets = new HashSet(); - 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..155bc0955 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 @@ -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; } 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..501ffa418 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,12 +25,12 @@ 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) { return true; 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 getBindingAnnotationTypePatterns() { List l = new ArrayList(); 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 getBindingTypePatterns() { List l = new ArrayList(); 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 key = annotationValues.keySet(); - for (Iterator 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 mungers = type.getInterTypeMungersIncludingSupers(); - for (Iterator 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/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 nodes = new TreeSet(new PointcutEvaluationExpenseComparator()); collectAndNodes(apc, nodes); // look for A and !A, or IfFalse - for (Iterator 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 keys = visitor.getIncorrectTargetKinds().keySet(); - for (Iterator 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 incorrectTargets = new ArrayList(); - 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 getExactTypes() { List ret = new ArrayList(); - 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> i = questionsAndAnswers.entrySet().iterator(); i.hasNext(); ) { - Map.Entry entry = i.next(); - Question question = (Question)entry.getKey(); - FuzzyBoolean expectedAnswer = (FuzzyBoolean)entry.getValue(); - + for (Map.Entry 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..35f2dc674 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()); @@ -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; } } @@ -368,8 +367,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { } else { s.writeInt(annotationValues.size()); Set key = annotationValues.keySet(); - for (Iterator 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..3dad2ce6b 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--; @@ -1160,16 +1158,16 @@ public class WildTypePattern extends TypePattern { // if (namePatterns.length != 1) return CollectionUtil.NO_STRINGS; List ret = new ArrayList(); - 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.indexOf("$") != -1) { + 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/* */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/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/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); } } -- cgit v1.2.3 From a508fd5315c6330f2057c219aebc35b15d0ea497 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 8 Aug 2020 03:09:01 +0200 Subject: 'while' loop replaceable with enhanced 'for' loop Reports while loops which iterate over collections, and can be replaced with an enhanced for loop (i.e. foreach iteration syntax). Signed-off-by: Lars Grefer --- .../ajde/core/internal/AjdeCoreBuildManager.java | 5 ++- .../ajde/internal/LstBuildConfigFileUpdater.java | 10 +++--- .../apache/bcel/generic/InstructionList.java | 4 +-- .../org/eclipse/jdt/core/dom/AjASTConverter.java | 42 ++++++++++------------ .../src/main/java/org/aspectj/weaver/Dump.java | 5 ++- .../java/org/aspectj/tools/ant/taskdefs/Ajc2.java | 16 ++++----- .../org/aspectj/weaver/bcel/BcelClassWeaver.java | 4 +-- .../java/org/aspectj/weaver/bcel/BcelShadow.java | 4 +-- .../org/aspectj/weaver/bcel/LazyMethodGen.java | 10 +++--- .../main/java/org/aspectj/weaver/bcel/Range.java | 4 +-- .../java/org/aspectj/weaver/bcel/ShadowRange.java | 4 +-- .../main/java/org/aspectj/weaver/bcel/Utility.java | 4 +-- 12 files changed, 44 insertions(+), 68 deletions(-) (limited to 'org.aspectj.matcher') diff --git a/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java b/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java index a83ab5be2..b64588001 100644 --- a/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java +++ b/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java @@ -177,9 +177,8 @@ public class AjdeCoreBuildManager { } StringBuffer formattedOptions = new StringBuffer(); - Iterator it = options.iterator(); - while (it.hasNext()) { - String o = it.next().toString(); + for (Object option : options) { + String o = option.toString(); if (formattedOptions.length() > 0) { formattedOptions.append(", "); } diff --git a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java index f3e2154cd..4e59e5d74 100644 --- a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java +++ b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java @@ -81,9 +81,8 @@ class LstBuildConfigFileUpdater { } public boolean exists(String entry, String configFile, String rootPath) { - Iterator it = readConfigFile(configFile).iterator(); - while (it.hasNext()) { - if ((entry).equals(rootPath + "/" + (String) it.next())) { + for (String s : readConfigFile(configFile)) { + if ((entry).equals(rootPath + "/" + s)) { return true; } } @@ -188,9 +187,8 @@ class LstBuildConfigFileUpdater { public void writeConfigFile(String filePath, List fileContents) { Set contentsSet = new TreeSet<>(fileContents); StringBuffer fileContentsSB = new StringBuffer(); - Iterator it = contentsSet.iterator(); - while (it.hasNext()) { - fileContentsSB.append(it.next().toString()); + for (String s : contentsSet) { + fileContentsSB.append(s.toString()); fileContentsSB.append("\n"); } writeFile(fileContentsSB.toString(), filePath); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java index dbdfb7fdb..dd010b758 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java @@ -703,9 +703,7 @@ public class InstructionList implements Serializable { Set targeters = ih.getTargeters(); boolean isOK = false; - Iterator tIter = targeters.iterator(); - while (tIter.hasNext()) { - InstructionTargeter instructionTargeter = tIter.next(); + for (InstructionTargeter instructionTargeter : targeters) { if (instructionTargeter.getClass().getName().endsWith("ShadowRange") || instructionTargeter.getClass().getName().endsWith("ExceptionRange") || instructionTargeter.getClass().getName().endsWith("LineNumberTag")) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java index 57602a440..32794ef44 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java @@ -1993,9 +1993,8 @@ public class AjASTConverter extends ASTConverter { if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding - Iterator tags = docComment.tags().listIterator(); - while (tags.hasNext()) { - recordNodes(javadoc, (TagElement) tags.next()); + for (Object o : docComment.tags()) { + recordNodes(javadoc, (TagElement) o); } } bodyDeclaration.setJavadoc(docComment); @@ -2016,9 +2015,8 @@ public class AjASTConverter extends ASTConverter { if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding - Iterator tags = docComment.tags().listIterator(); - while (tags.hasNext()) { - recordNodes(javadoc, (TagElement) tags.next()); + for (Object o : docComment.tags()) { + recordNodes(javadoc, (TagElement) o); } } packageDeclaration.setJavadoc(docComment); @@ -3389,9 +3387,8 @@ public class AjASTConverter extends ASTConverter { } protected void recordNodes(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, TagElement tagElement) { - Iterator fragments = tagElement.fragments().listIterator(); - while (fragments.hasNext()) { - ASTNode node = (ASTNode) fragments.next(); + for (Object value : tagElement.fragments()) { + ASTNode node = (ASTNode) value; if (node.getNodeType() == ASTNode.MEMBER_REF) { MemberRef memberRef = (MemberRef) node; Name name = memberRef.getName(); @@ -3404,16 +3401,16 @@ public class AjASTConverter extends ASTConverter { } // Replace qualifier to have all nodes recorded if (memberRef.getQualifier() != null) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null; + TypeReference typeRef = null; if (compilerNode instanceof JavadocFieldReference) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocFieldReference) compilerNode).receiver; - if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { - typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression; + if (expression instanceof TypeReference) { + typeRef = (TypeReference) expression; } } else if (compilerNode instanceof JavadocMessageSend) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocMessageSend) compilerNode).receiver; - if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { - typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression; + if (expression instanceof TypeReference) { + typeRef = (TypeReference) expression; } } if (typeRef != null) { @@ -3431,16 +3428,16 @@ public class AjASTConverter extends ASTConverter { if (compilerNode != null) { recordNodes(methodRef, compilerNode); // get type ref - org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null; + TypeReference typeRef = null; if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression) { typeRef = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression) compilerNode).type; if (typeRef != null) { recordNodes(name, compilerNode); } - } else if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) compilerNode).receiver; - if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { - typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression; + } else if (compilerNode instanceof JavadocMessageSend) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocMessageSend) compilerNode).receiver; + if (expression instanceof TypeReference) { + typeRef = (TypeReference) expression; } // TODO (frederic) remove following line to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=62650 recordNodes(name, compilerNode); @@ -3451,16 +3448,15 @@ public class AjASTConverter extends ASTConverter { } } // Resolve parameters - Iterator parameters = methodRef.parameters().listIterator(); - while (parameters.hasNext()) { - MethodRefParameter param = (MethodRefParameter) parameters.next(); + for (Object o : methodRef.parameters()) { + MethodRefParameter param = (MethodRefParameter) o; org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) javadoc .getNodeStartingAt(param.getStartPosition()); if (expression != null) { recordNodes(param, expression); if (expression instanceof JavadocArgumentExpression) { JavadocArgumentExpression argExpr = (JavadocArgumentExpression) expression; - org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = argExpr.argument.type; + TypeReference typeRef = argExpr.argument.type; if (this.ast.apiLevel >= AST.JLS3) { param.setVarargs(argExpr.argument.isVarArgs()); } 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 6e48de0d2..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 @@ -424,9 +424,8 @@ public class Dump { } 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); } diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java index a089f00b9..9aea9ae6d 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java @@ -416,11 +416,10 @@ public class Ajc2 extends Javac { List newIncludes = new ArrayList(); List newArguments = new ArrayList(); if (argfiles != null) { - Iterator iter = argfiles.iterator(); - while (iter.hasNext()) { - File argfile = ((Argfile)iter.next()).getFile(); - expandArgfile(argfile, newIncludes, newArguments); - } + for (Object o : argfiles) { + File argfile = ((Argfile) o).getFile(); + expandArgfile(argfile, newIncludes, newArguments); + } } // If there aren't any includes, but we've used an argfile then we should @@ -445,10 +444,9 @@ public class Ajc2 extends Javac { } // Add the new included files - Iterator iter = newIncludes.iterator(); - while (iter.hasNext()) { - newFiles.add((File)iter.next()); - } + for (Object newInclude : newIncludes) { + newFiles.add((File) newInclude); + } // This is the same behavior found in Javac int newFileSize = newFiles.size(); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java index 3c4f64aa2..36cd2686e 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -2324,9 +2324,7 @@ class BcelClassWeaver implements IClassWeaver { // copy over tags and range attributes - Iterator tIter = src.getTargeters().iterator(); - while (tIter.hasNext()) { - InstructionTargeter old = tIter.next(); + for (InstructionTargeter old : src.getTargeters()) { if (old instanceof Tag) { Tag oldTag = (Tag) old; Tag fresh = tagMap.get(oldTag); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java index ca167e2ef..e92667b2e 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java @@ -555,9 +555,7 @@ public class BcelShadow extends Shadow { if (startOfHandler.getInstruction().isStoreInstruction() && startOfHandler.getNext() != null) { int slot = startOfHandler.getInstruction().getIndex(); // System.out.println("got store: " + startOfHandler.getInstruction() + ", " + index); - Iterator tIter = startOfHandler.getNext().getTargeters().iterator(); - while (tIter.hasNext()) { - InstructionTargeter targeter = tIter.next(); + for (InstructionTargeter targeter : startOfHandler.getNext().getTargeters()) { if (targeter instanceof LocalVariableTag) { LocalVariableTag t = (LocalVariableTag) targeter; if (t.getSlot() == slot) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java index ed9dd2c7a..049257d48 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -658,9 +658,8 @@ public final class LazyMethodGen implements Traceable { // boolean hasPendingTargeters = false; int lcounter = 0; for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) { - Iterator tIter = ih.getTargeters().iterator(); - while (tIter.hasNext()) { - InstructionTargeter t = tIter.next();// targeters + // targeters + for (InstructionTargeter t : ih.getTargeters()) { // [ // i // ] @@ -1708,9 +1707,8 @@ public final class LazyMethodGen implements Traceable { // } private static void assertTargetedBy(InstructionHandle target, InstructionTargeter targeter, String from) { - Iterator tIter = target.getTargeters().iterator(); - while (tIter.hasNext()) { - if (((InstructionTargeter) tIter.next()) == targeter) { + for (InstructionTargeter instructionTargeter : target.getTargeters()) { + if (instructionTargeter == targeter) { return; } } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java b/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java index fa162c526..ebcb4251c 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java @@ -194,9 +194,7 @@ abstract class Range implements InstructionTargeter { protected static final Range getRange(InstructionHandle ih) { // assert isRangeHandle(ih) Range ret = null; - Iterator tIter = ih.getTargeters().iterator(); - while (tIter.hasNext()) { - InstructionTargeter targeter = tIter.next(); + for (InstructionTargeter targeter : ih.getTargeters()) { if (targeter instanceof Range) { Range r = (Range) targeter; if (r.getStart() != ih && r.getEnd() != ih) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java index 47c8400c5..966699c04 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java @@ -190,9 +190,7 @@ final class ShadowRange extends Range { // now go through again and update variable slots that have been altered as a result // of remapping... for (InstructionHandle newIh = freshBody.getStart(); newIh != freshBody.getEnd(); newIh = newIh.getNext()) { - Iterator tIter = newIh.getTargeters().iterator(); - while (tIter.hasNext()) { - InstructionTargeter source = tIter.next(); + for (InstructionTargeter source : newIh.getTargeters()) { if (source instanceof LocalVariableTag) { LocalVariableTag lvt = (LocalVariableTag) source; if (!lvt.isRemapped() && remap.hasKey(lvt.getSlot())) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java index 7279070bc..bb4a38817 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java @@ -580,9 +580,7 @@ public class Utility { if (ih == null) { return -1; } - Iterator tIter = ih.getTargeters().iterator(); - while (tIter.hasNext()) { - InstructionTargeter t = tIter.next(); + for (InstructionTargeter t : ih.getTargeters()) { if (t instanceof LineNumberTag) { return ((LineNumberTag) t).getLineNumber(); } -- cgit v1.2.3 From c1c373f4278426308689db61f7758185e8f0401b Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 8 Aug 2020 03:11:12 +0200 Subject: 'String.indexOf()' expression is replaceable with 'contains()' Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer. Signed-off-by: Lars Grefer --- .../org/aspectj/ajde/core/AjdeCoreTestCase.java | 2 +- .../ajde/core/TestBuildProgressMonitor.java | 4 +-- .../org/aspectj/ajde/core/tests/InpathTest.java | 6 ++-- .../aspectj/ajde/core/tests/ResourceCopyTest.java | 4 +-- .../aspectj/ajde/ui/StructureSearchManager.java | 2 +- .../test/java/org/aspectj/ajde/ExtensionTest.java | 4 +-- .../ajde/internal/LstBuildConfigManagerTest.java | 4 +-- .../ajde/ui/utils/TestBuildProgressMonitor.java | 4 +-- .../org/aspectj/tools/ajdoc/HtmlDecorator.java | 8 ++--- .../org/aspectj/tools/ajdoc/StubFileGenerator.java | 2 +- .../aspectj/tools/ajdoc/AjdocOutputChecker.java | 38 +++++++++++----------- .../asm/internal/JDTLikeHandleProvider.java | 8 ++--- .../org/aspectj/asm/internal/ProgramElement.java | 2 +- .../org/aspectj/apache/bcel/classfile/Utility.java | 2 +- .../bcel/classfile/tests/AnnotationGenTest.java | 4 +-- .../bcel/classfile/tests/ElementValueGenTest.java | 2 +- .../classfile/tests/ParameterAnnotationsTest.java | 8 ++--- .../aspectj/apache/bcel/util/ClassPathTests.java | 2 +- .../main/java/org/aspectj/bridge/MessageUtil.java | 2 +- .../internal/tools/ant/taskdefs/AntBuilder.java | 4 +-- .../internal/tools/ant/taskdefs/Checklics.java | 4 +-- .../org/aspectj/internal/tools/build/Builder.java | 2 +- .../org/aspectj/internal/tools/build/Module.java | 4 +-- .../weaver/loadtime/ClassLoaderWeavingAdaptor.java | 2 +- .../weaver/loadtime/ConcreteAspectCodeGen.java | 4 +-- .../weaver/loadtime/WeavingURLClassLoaderTest.java | 6 ++-- .../java/org/aspectj/ajdt/ajc/AjdtCommand.java | 4 +-- .../internal/compiler/ast/PointcutDeclaration.java | 2 +- .../compiler/problem/AjProblemReporter.java | 16 ++++----- .../ajdt/internal/core/builder/AjBuildConfig.java | 2 +- .../ajdt/internal/core/builder/AjBuildManager.java | 6 ++-- .../ajdt/internal/core/builder/AjState.java | 2 +- .../internal/core/builder/AsmElementFormatter.java | 2 +- .../internal/core/builder/EclipseAdapterUtils.java | 2 +- .../src/main/java/org/aspectj/tools/ajc/Main.java | 2 +- .../org/aspectj/ajdt/ajc/AjdtCommandTestCase.java | 14 ++++---- .../aspectj/ajdt/ajc/BuildArgParserTestCase.java | 10 +++--- .../ajdt/internal/compiler/batch/DumpTestCase.java | 2 +- .../internal/core/builder/AjBuildManagerTest.java | 2 +- .../java/org/aspectj/tools/ajc/AjcTestCase.java | 8 ++--- .../main/java/org/aspectj/weaver/NameMangler.java | 2 +- .../org/aspectj/weaver/ResolvedMemberImpl.java | 2 +- .../main/java/org/aspectj/weaver/ResolvedType.java | 2 +- .../main/java/org/aspectj/weaver/ShadowMunger.java | 2 +- .../java/org/aspectj/weaver/UnresolvedType.java | 6 ++-- .../src/main/java/org/aspectj/weaver/Utils.java | 2 +- .../src/main/java/org/aspectj/weaver/World.java | 4 +-- .../weaver/patterns/WildAnnotationTypePattern.java | 4 +-- .../aspectj/weaver/patterns/WildTypePattern.java | 2 +- .../aspectj/weaver/patterns/BindingTestCase.java | 2 +- .../internal/lang/reflect/StringToType.java | 2 +- .../aspectj/internal/lang/reflect/AjTypeTest.java | 4 +-- .../lang/reflect/AjTypeWithAspectsTest.java | 6 ++-- .../test/java/org/aspectj/runtime/RuntimeTest.java | 8 ++--- .../java/org/aspectj/tools/ant/taskdefs/Ajc2.java | 2 +- .../org/aspectj/tools/ant/taskdefs/AjcTask.java | 6 ++-- .../aspectj/tools/ant/taskdefs/AjcTaskTest.java | 8 ++--- .../test/java/org/aspectj/testing/TesterTest.java | 2 +- .../java/org/aspectj/testing/drivers/Harness.java | 4 +-- .../java/org/aspectj/testing/util/TestUtil.java | 2 +- .../java/org/aspectj/testingutil/TestUtilTest.java | 2 +- .../src/test/java/org/aspectj/testing/AntSpec.java | 4 +-- .../test/java/org/aspectj/testing/CompileSpec.java | 2 +- .../test/java/org/aspectj/testing/OutputSpec.java | 4 +-- .../aspectj/testing/harness/bridge/AjcTest.java | 2 +- .../harness/bridge/CompilerRunSpecTest.java | 6 ++-- .../testing/harness/bridge/CompilerRunTest.java | 2 +- .../testing/harness/bridge/FlatSuiteReader.java | 10 +++--- .../aspectj/testing/harness/bridge/JavaRun.java | 4 +-- .../java/org/aspectj/testing/util/BridgeUtil.java | 4 +-- .../test/java/org/aspectj/testing/util/Diffs.java | 2 +- .../java/org/aspectj/testing/util/FileUtil.java | 2 +- .../java/org/aspectj/testing/util/LangUtil.java | 10 +++--- .../java/org/aspectj/testing/util/LinkCheck.java | 4 +-- .../org/aspectj/testing/util/ValidFileFilter.java | 2 +- .../testing/util/options/OptionChecker.java | 4 +-- .../java/org/aspectj/testing/xml/XMLWriter.java | 2 +- .../org/aspectj/systemtest/ajc121/Ajc121Tests.java | 20 ++++++------ .../org/aspectj/systemtest/ajc150/Ajc150Tests.java | 2 +- .../ajc152/SynchronizationTransformTests.java | 2 +- .../ajc153/JDTLikeHandleProviderTests.java | 4 +-- .../org/aspectj/systemtest/ajc161/Ajc161Tests.java | 2 +- .../org/aspectj/systemtest/ajc165/Ajc165Tests.java | 2 +- .../aspectj/systemtest/ajc169/IntertypeTests.java | 4 +-- .../systemtest/incremental/IncrementalTests.java | 2 +- ...tiProjectIncrementalAjdeInteractionTestbed.java | 6 ++-- .../incremental/tools/AjdeInteractionTestbed.java | 2 +- .../tools/MoreOutputLocationManagerTests.java | 6 ++-- .../tools/MultiProjectIncrementalTests.java | 21 ++++++------ .../tools/OutputLocationManagerTests.java | 6 ++-- util/src/main/java/org/aspectj/util/FileUtil.java | 2 +- util/src/main/java/org/aspectj/util/LangUtil.java | 4 +-- .../test/java/org/aspectj/util/FileUtilTest.java | 2 +- .../aspectj/util/GenericSignatureParserTest.java | 2 +- .../test/java/org/aspectj/util/LangUtilTest.java | 6 ++-- .../org/aspectj/weaver/bcel/AtAjAttributes.java | 2 +- .../org/aspectj/weaver/bcel/BcelTypeMunger.java | 2 +- .../java/org/aspectj/weaver/bcel/BcelWorld.java | 4 +-- .../weaver/bcel/ExtensibleURLClassLoader.java | 2 +- .../main/java/org/aspectj/weaver/bcel/Utility.java | 2 +- .../weaver/model/AsmRelationshipProvider.java | 6 ++-- .../test/java/org/aspectj/weaver/DumpTestCase.java | 2 +- .../AnnotationPatternMatchingTestCase.java | 4 +-- .../tools/PointcutDesignatorHandlerTest.java | 2 +- .../aspectj/weaver/tools/PointcutParserTest.java | 6 ++-- 105 files changed, 235 insertions(+), 238 deletions(-) (limited to 'org.aspectj.matcher') diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java index eafa22f04..c692d6d50 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java @@ -125,7 +125,7 @@ public abstract class AjdeCoreTestCase extends TestCase { public boolean checkFor(String what) { List ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages(); for (TestMessage element: ll) { - if (element.toString().indexOf(what) != -1) + if (element.toString().contains(what)) return true; } return false; diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java index 2a293b626..e214faeae 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java @@ -52,7 +52,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { if (text.startsWith("woven class ")) numWovenClassMessages++; if (text.startsWith("compiled:")) numCompiledMessages++; if (programmableString != null - && text.indexOf(programmableString) != -1) { + && text.contains(programmableString)) { count--; if (count==0) { if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); @@ -76,7 +76,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { public boolean containsMessage(String prefix,String distinguishingMarks) { for (String element: messagesReceived) { if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks)!=-1) return true; + element.contains(distinguishingMarks)) return true; } return false; } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java index 0696aa908..2d1b3fd7c 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java @@ -242,7 +242,7 @@ public class InpathTest extends AjdeCoreTestCase { while (null != (entry = outjar.getNextEntry())) { String fileName = entry.getName(); fileName = fileName.replace('\\', '/'); - if (fileName.indexOf("CVS") == -1) { + if (!fileName.contains("CVS")) { boolean b = expectedOutputJarContents.remove(fileName); assertTrue("Unexpectedly found : " + fileName + " in outjar", b); } @@ -295,7 +295,7 @@ public class InpathTest extends AjdeCoreTestCase { File binBase = openFile(outdirName); String[] toResources = FileUtil.listFiles(binBase); for (String fileName : toResources) { - if (fileName.indexOf("CVS") == -1) { + if (!fileName.contains("CVS")) { boolean b = expectedOutdirContents.remove(fileName); assertTrue("Extraneous resources: " + fileName, b); } @@ -310,7 +310,7 @@ public class InpathTest extends AjdeCoreTestCase { for (File fromResource : fromResources) { String name = FileUtil.normalizedPath(fromResource, srcBase); // System.err.println("Checking "+name); - if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { + if (!name.startsWith("CVS/") && (!name.contains("/CVS/")) && !name.endsWith("/CVS")) { resources.add(name); } } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java index b6f44ae7d..889e2e5ce 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java @@ -169,7 +169,7 @@ public class ResourceCopyTest extends AjdeCoreTestCase { File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter); for (File fromResource : fromResources) { String name = FileUtil.normalizedPath(fromResource, srcBase); - if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { + if (!name.startsWith("CVS/") && (!name.contains("/CVS/")) && !name.endsWith("/CVS")) { resources.add(name); } } @@ -179,7 +179,7 @@ public class ResourceCopyTest extends AjdeCoreTestCase { @Override public boolean accept(File pathname) { String name = pathname.getName().toLowerCase(); - boolean isCVSRelated = name.indexOf("/cvs/") != -1; + boolean isCVSRelated = name.contains("/cvs/"); return (!isCVSRelated && !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj")); } }; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java index d9e9a0f52..8839b00da 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java @@ -45,7 +45,7 @@ public class StructureSearchManager { private List findMatchesHelper(IProgramElement node, String pattern, IProgramElement.Kind kind, List matches) { - if (node != null && node.getName().indexOf(pattern) != -1) { + if (node != null && node.getName().contains(pattern)) { if (kind == null || node.getKind().equals(kind)) { matches.add(node); } diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java index a8ce3d922..ce0269930 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java @@ -79,7 +79,7 @@ public class ExtensionTest extends AjcTestCase { private IProgramElement getChild(IProgramElement parent, String s) { List kids = parent.getChildren(); for (IProgramElement element : kids) { - if (element.getName().indexOf(s) != -1) + if (element.getName().contains(s)) return element; } return null; @@ -90,7 +90,7 @@ public class ExtensionTest extends AjcTestCase { private void findChild(String s, IProgramElement ipe) { if (ipe == null) return; - if (ipe.getName().indexOf(s) != -1) { + if (ipe.getName().contains(s)) { foundNode = ipe; return; } diff --git a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java index c80f33bb6..fe642ff95 100644 --- a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -53,7 +53,7 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { doBuild("bad-injar.lst"); messages = getMessages("bad-injar.lst"); message = (TestMessage)messages.get(0); - assertTrue(message.getContainedMessage().getMessage().indexOf("skipping missing, empty or corrupt inpath entry") != -1); + assertTrue(message.getContainedMessage().getMessage().contains("skipping missing, empty or corrupt inpath entry")); } public void testErrorMessages() throws IOException { @@ -63,7 +63,7 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { List messages = getMessages("invalid-entry.lst"); TestMessage message = (TestMessage)messages.get(0); - assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().indexOf("aaa.bbb") != -1); + assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().contains("aaa.bbb")); } diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java index 6ccddefc0..09d794191 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java @@ -55,7 +55,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { if (text.startsWith("woven class ")) numWovenClassMessages++; if (text.startsWith("compiled:")) numCompiledMessages++; if (programmableString != null - && text.indexOf(programmableString) != -1) { + && text.contains(programmableString)) { count--; if (count==0) { if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); @@ -80,7 +80,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { for (Object o : messagesReceived) { String element = (String) o; if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks) != -1) return true; + element.contains(distinguishingMarks)) return true; } return false; } diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java index 35e84ca5a..44708bb01 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -192,7 +192,7 @@ class HtmlDecorator { } // only add aspect documentation if we're in the correct // file for the given IProgramElement - if (file.getName().indexOf(fullname + ".html") != -1) { + if (file.getName().contains(fullname + ".html")) { addAspectDocumentation(decl, fileContents, index); } } else { @@ -202,7 +202,7 @@ class HtmlDecorator { // moved this here because then can use the IProgramElement.Kind // rather than checking to see if there's advice - this fixes // the case with an inner aspect not having the title "Aspect" - if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().indexOf(decl.toSignatureString()) != -1) { + if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().contains(decl.toSignatureString())) { // only want to change "Class" to "Aspect" if we're in the // file corresponding to the IProgramElement String fullname = ""; @@ -212,7 +212,7 @@ class HtmlDecorator { } else { fullname += decl.toSignatureString(); } - if (file.getName().indexOf(fullname + ".html") == -1) { + if (!file.getName().contains(fullname + ".html")) { // we're still in the file for a parent IPE continue; } @@ -746,7 +746,7 @@ class HtmlDecorator { */ private static String getRelativePathFromHere(String packagePath) { StringBuffer result = new StringBuffer(""); - if (packagePath != null && (packagePath.indexOf("/") != -1)) { + if (packagePath != null && (packagePath.contains("/"))) { StringTokenizer sTok = new StringTokenizer(packagePath, "/", false); while (sTok.hasMoreTokens()) { sTok.nextToken(); // don't care about the token value diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java index cd8a01e26..4b9301ce8 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -153,7 +153,7 @@ class StubFileGenerator { if (member.getKind().equals(IProgramElement.Kind.METHOD) || member.getKind().equals(IProgramElement.Kind.CONSTRUCTOR)) { - if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.indexOf("abstract ") != -1) { + if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.contains("abstract ")) { writer.println(";"); } else { writer.println(" { }"); diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java index b22d1250d..797c76660 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java @@ -41,7 +41,7 @@ public class AjdocOutputChecker { BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(requiredString) != -1) { + if (line.contains(requiredString)) { reader.close(); return true; } @@ -89,11 +89,11 @@ public class AjdocOutputChecker { BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(sectionHeader) != -1) { + if (line.contains(sectionHeader)) { String nextLine = reader.readLine(); while (nextLine != null && - (nextLine.indexOf("========") == -1)) { - if (nextLine.indexOf(requiredString) != -1) { + (!nextLine.contains("========"))) { + if (nextLine.contains(requiredString)) { reader.close(); return true; } @@ -151,11 +151,11 @@ public class AjdocOutputChecker { BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf("START OF CLASS DATA") != -1) { + if (line.contains("START OF CLASS DATA")) { // found the required class data section String subLine = reader.readLine(); while(subLine != null - && (subLine.indexOf("========") == -1)){ + && (!subLine.contains("========"))){ int relIndex = subLine.indexOf(relationship.toString()); int targetIndex = subLine.indexOf(target); if ((relIndex != -1) && (targetIndex != -1)) { @@ -195,24 +195,24 @@ public class AjdocOutputChecker { if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) { return false; } - if (sectionHeader.indexOf("DETAIL") == -1) { + if (!sectionHeader.contains("DETAIL")) { return false; } BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(sectionHeader) != -1) { + if (line.contains(sectionHeader)) { // found the required main section String nextLine = reader.readLine(); - while (nextLine != null && (nextLine.indexOf("========") == -1)) { + while (nextLine != null && (!nextLine.contains("========"))) { // On JDK11 it looks like on earlier JDKs it can look like - if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) || - nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) { + if ((LangUtil.is11VMOrGreater() && nextLine.contains("ID=\"" + source + "\"") || nextLine.contains("id=\"" + source + "\"")) || + nextLine.contains("NAME=\"" + source + "\"") || nextLine.contains("name=\"" + source + "\"")) { // found the required subsection String subLine = reader.readLine(); while(subLine != null - && (subLine.indexOf("========") == -1) - && (subLine.indexOf("NAME") == -1 && subLine.indexOf("name") == -1)) { + && (!subLine.contains("========")) + && (!subLine.contains("NAME") && !subLine.contains("name"))) { int relIndex = subLine.indexOf(relationship.toString()); int targetIndex = subLine.indexOf(target); if ((relIndex != -1) && (targetIndex != -1)) { @@ -259,22 +259,22 @@ public class AjdocOutputChecker { if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) { return false; } - if (sectionHeader.indexOf("SUMMARY") == -1) { + if (!sectionHeader.contains("SUMMARY")) { return false; } BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(sectionHeader) != -1) { + if (line.contains(sectionHeader)) { // found the required main section String nextLine = reader.readLine(); - while (nextLine != null && (nextLine.indexOf("========") == -1)) { - if (nextLine.indexOf(source) != -1) { + while (nextLine != null && (!nextLine.contains("========"))) { + if (nextLine.contains(source)) { // found the required subsection String subLine = nextLine; while(subLine != null - && (subLine.indexOf("========") == -1) - && (subLine.indexOf("") == -1)) { + && (!subLine.contains("========")) + && (!subLine.contains(""))) { int relIndex = subLine.indexOf(relationship.toString()); int targetIndex = subLine.indexOf(target); if ((relIndex != -1) && (targetIndex != -1)) { diff --git a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java index 15eb990ee..5e518c51f 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -73,7 +73,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { if (folder.endsWith("/")) { folder = folder.substring(0, folder.length() - 1); } - if (folder.indexOf("/") != -1) { + if (folder.contains("/")) { folder = folder.replace("/", "\\/"); } sb.append(folder); @@ -211,7 +211,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { // this code needs a speed overhaul... and some proper tests // Two static parts because one may be enclosing jpsp (269522) if (sig1 != null) { - if (sig1.indexOf("Lorg/aspectj/lang") != -1) { + if (sig1.contains("Lorg/aspectj/lang")) { if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } @@ -263,7 +263,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { // this code needs a speed overhaul... and some proper tests // Two static parts because one may be enclosing jpsp (269522) if (sig1 != null) { - if (sig1.indexOf("Lorg/aspectj/lang") != -1) { + if (sig1.contains("Lorg/aspectj/lang")) { if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } @@ -358,7 +358,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { ipeSig = ipeSig.substring(0, idx); } if (ipeSig != null) { - if (ipeSig.indexOf("Lorg/aspectj/lang") != -1) { + if (ipeSig.contains("Lorg/aspectj/lang")) { if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } diff --git a/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java b/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java index c1479f70f..77fe7a66b 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java @@ -432,7 +432,7 @@ public class ProgramElement implements IProgramElement { // check if someone is calling us with something that is a signature already assert name.charAt(0) != '['; - if (name.indexOf("<") == -1) { + if (!name.contains("<")) { // not parameterized return new StringBuilder("L").append(name.replace('.', '/')).append(';').toString(); } else { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java index 2d4b2a81f..9168847b0 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java @@ -243,7 +243,7 @@ public abstract class Utility { StringBuffer buf = new StringBuffer("("); String type; int index; - int var_index = (access.indexOf("static") >= 0) ? 0 : 1; + int var_index = (access.contains("static")) ? 0 : 1; try { // Read all declarations between for `(' and `)' if (signature.charAt(0) != '(') { diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java index 426ebbea9..d9a4ce780 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java @@ -60,7 +60,7 @@ public class AnnotationGenTest extends BcelTestCase { NameValuePair nvGen = new NameValuePair("id", evg, cp); // Check it looks right - assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1); + assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().contains("id=4")); ObjectType t = new ObjectType("SimpleAnnotation"); @@ -87,7 +87,7 @@ public class AnnotationGenTest extends BcelTestCase { NameValuePair nvGen = new NameValuePair("id", evg, cp); // Check it looks right - assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1); + assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().contains("id=4")); ObjectType t = new ObjectType("SimpleAnnotation"); diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java index 7d91bd7d3..ec7645aeb 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java @@ -187,7 +187,7 @@ public class ElementValueGenTest extends BcelTestCase { ClassElementValue evg = new ClassElementValue(classType, cp); assertTrue("Unexpected value for contained class: '" + evg.getClassString() + "'", - evg.getClassString().indexOf("Integer") != -1); + evg.getClassString().contains("Integer")); checkSerialize(evg, cp); } diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java index f49b4fb46..351caa002 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java @@ -75,9 +75,9 @@ public class ParameterAnnotationsTest extends BcelTestCase { AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0); assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2); assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(), - annos[0].toString().indexOf("fruit=Apples")!=-1); + annos[0].toString().contains("fruit=Apples")); assertTrue("This annotation should contain the string 'fruit=Oranges' but it is "+annos[1].toString(), - annos[1].toString().indexOf("fruit=Oranges")!=-1); + annos[1].toString().contains("fruit=Oranges")); } @@ -105,9 +105,9 @@ public class ParameterAnnotationsTest extends BcelTestCase { AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0); assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2); assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(), - annos[0].toString().indexOf("fruit=Apples")!=-1); + annos[0].toString().contains("fruit=Apples")); assertTrue("This annotation should contain the string 'fruit=Oranges' but it is "+annos[1].toString(), - annos[1].toString().indexOf("fruit=Oranges")!=-1); + annos[1].toString().contains("fruit=Oranges")); assertTrue(wipe("temp5","HelloWorld.class")); } diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java index 711011213..53488df0e 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java @@ -9,7 +9,7 @@ public class ClassPathTests extends BcelTestCase { public void testJava9ImageFile() throws IOException { String sunbootClasspath = System.getProperty("sun.boot.class.path"); - if (sunbootClasspath==null || sunbootClasspath.indexOf(".jimage")==-1) { + if (sunbootClasspath==null || !sunbootClasspath.contains(".jimage")) { // Not java9 return; } diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java index 0393a5a58..77f9c90a8 100644 --- a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java +++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java @@ -587,7 +587,7 @@ public class MessageUtil { return true; } String text = message.getMessage(); - return (text.indexOf(infix) != -1); + return (text.contains(infix)); } public void ignore(Kind kind) { diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index bef3fb0aa..12286748e 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -61,10 +61,10 @@ public class AntBuilder extends Builder { boolean useEclipseCompiles = false; boolean verbose = false; if (null != config) { - if (-1 != config.indexOf("useEclipseCompiles")) { + if (config.contains("useEclipseCompiles")) { useEclipseCompiles = true; } - if (-1 != config.indexOf("verbose")) { + if (config.contains("verbose")) { verbose = true; } } diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index afa3c71d3..aa0c35e35 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -422,7 +422,7 @@ public class Checklics extends MatchingTask { if ((null == line) || (0 == line.length())) { return; } - if (!gotLicense && (null != license) && (-1 != line.indexOf(license))) { + if (!gotLicense && (null != license) && (line.contains(license))) { gotLicense = true; } if (!gotCopyright && (null != copyright)) { @@ -670,7 +670,7 @@ class Header { start = loc + 4; } - return (-1 != line.indexOf("*/")); + return (line.contains("*/")); } } // class Header diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java index 1d7bfa7d8..fe80190ad 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java @@ -251,7 +251,7 @@ public abstract class Builder { */ protected Result specifyResultFor(BuildSpec buildSpec) { if (buildSpec.trimTesting - && (-1 != buildSpec.module.indexOf("testing"))) { // XXXNameLiteral + && (buildSpec.module.contains("testing"))) { // XXXNameLiteral String warning = "Warning - cannot trimTesting for testing modules: "; handler.log(warning + buildSpec.module); } diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Module.java b/build/src/main/java/org/aspectj/internal/tools/build/Module.java index acc8fd90b..65d929707 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Module.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Module.java @@ -444,7 +444,7 @@ public class Module { if (path.equals("org.eclipse.ajdt.core.ASPECTJRT_CONTAINER")) { classpathVariables.add("ASPECTJRT_LIB"); } else { - if (-1 == path.indexOf("JRE")) { // warn non-JRE containers + if (!path.contains("JRE")) { // warn non-JRE containers messager.log("cannot handle con yet: " + toString); } } @@ -614,7 +614,7 @@ public class Module { boolean inQuote = false; while (st.hasMoreTokens()) { String s = st.nextToken(); - if ((1 == s.length()) && (-1 != DELIM.indexOf(s))) { + if ((1 == s.length()) && (DELIM.contains(s))) { if ("\"".equals(s)) { // end quote (or escaped) if (inQuote) { inQuote = false; diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 173310591..5827f2e64 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -662,7 +662,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { * Checks if the pattern looks like "com.foo.Bar" - an exact name */ private String looksLikeExactName(String typePattern) { - if (hasSpaceAnnotationPlus(typePattern, 0) || typePattern.indexOf("*") != -1) { + if (hasSpaceAnnotationPlus(typePattern, 0) || typePattern.contains("*")) { return null; } return typePattern.replace('$', '.'); diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java index 6f5b58702..7f87e40c9 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java @@ -164,7 +164,7 @@ public class ConcreteAspectCodeGen { String parentAspectName = concreteAspect.extend; - if (parentAspectName.indexOf("<") != -1) { + if (parentAspectName.contains("<")) { // yikes, generic parent parent = world.resolve(UnresolvedType.forName(parentAspectName), true); if (parent.isMissing()) { @@ -741,7 +741,7 @@ public class ConcreteAspectCodeGen { return null; } String clazz = value.substring(0, value.length() - 6); - boolean qualified = clazz.indexOf(".") != -1; + boolean qualified = clazz.contains("."); if (!qualified) { // if not qualified, have to assume java.lang clazz = "java.lang." + clazz; diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java index 406847eb2..5ae1d50e3 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java @@ -359,7 +359,7 @@ public class WeavingURLClassLoaderTest extends TestCase { } catch (Exception ex) { // Expecting: java.lang.NoClassDefFoundError: LTWAspect String m = ex.getMessage(); - if (-1 == m.indexOf("java.lang.NoClassDefFoundError")) { + if (!m.contains("java.lang.NoClassDefFoundError")) { fail("Expecting java.lang.NoClassDefFoundError but caught " + ex); } } @@ -426,7 +426,7 @@ public class WeavingURLClassLoaderTest extends TestCase { // expecting error String message = ex.getMessage(); // expecting error - seems to be wrapped wrong - if (-1 == message.indexOf("around advice")) { + if (!message.contains("around advice")) { failWithException(ex); } } catch (Error ex) { @@ -461,7 +461,7 @@ public class WeavingURLClassLoaderTest extends TestCase { invokeMain(clazz, new String[] {}); fail("Should reject bad aspect MissingFile"); } catch (AbortException ae) { - assertTrue("Unexpected cause: " + ae.getMessage(), ae.getMessage().indexOf("bad aspect library") != -1); + assertTrue("Unexpected cause: " + ae.getMessage(), ae.getMessage().contains("bad aspect library")); } } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java index 25de41c2d..7fa4e9c36 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java @@ -168,9 +168,9 @@ public class AjdtCommand implements ICommand { /** @return IMessage.WARNING unless message contains error or info */ protected static IMessage.Kind inferKind(String message) { // XXX dubious - if (-1 != message.indexOf("error")) { + if (message.contains("error")) { return IMessage.ERROR; - } else if (-1 != message.indexOf("info")) { + } else if (message.contains("info")) { return IMessage.INFO; } else { return IMessage.WARNING; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java index 70a610950..365f56940 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java @@ -139,7 +139,7 @@ public class PointcutDeclaration extends AjMethodDeclaration { public String getPointcutText() { String text = getPointcut().toString(); - if (text.indexOf("BindingTypePattern") == -1) + if (!text.contains("BindingTypePattern")) return text; // has been wrecked by resolution, try to reconstruct from tokens if (pointcutDesignator != null) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index ec5a2a545..c42a503c6 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -325,25 +325,25 @@ public class AjProblemReporter extends ProblemReporter { String name = new String(binding.selector); if (name.startsWith("ajc$")) { long metaTagBits = annotation.resolvedType.getAnnotationTagBits(); // could be forward reference - if (name.indexOf("interField") != -1) { + if (name.contains("interField")) { if ((metaTagBits & TagBits.AnnotationForField) != 0) return; - } else if (name.indexOf("interConstructor") != -1) { + } else if (name.contains("interConstructor")) { if ((metaTagBits & TagBits.AnnotationForConstructor) != 0) return; - } else if (name.indexOf("interMethod") != -1) { + } else if (name.contains("interMethod")) { if ((metaTagBits & TagBits.AnnotationForMethod) != 0) return; - } else if (name.indexOf("declare_" + DeclareAnnotation.AT_TYPE + "_") != -1) { + } else if (name.contains("declare_" + DeclareAnnotation.AT_TYPE + "_")) { if ((metaTagBits & TagBits.AnnotationForAnnotationType) != 0 || (metaTagBits & TagBits.AnnotationForType) != 0) return; - } else if (name.indexOf("declare_" + DeclareAnnotation.AT_FIELD + "_") != -1) { + } else if (name.contains("declare_" + DeclareAnnotation.AT_FIELD + "_")) { if ((metaTagBits & TagBits.AnnotationForField) != 0) return; - } else if (name.indexOf("declare_" + DeclareAnnotation.AT_CONSTRUCTOR + "_") != -1) { + } else if (name.contains("declare_" + DeclareAnnotation.AT_CONSTRUCTOR + "_")) { if ((metaTagBits & TagBits.AnnotationForConstructor) != 0) return; - } else if (name.indexOf("declare_eow") != -1) { + } else if (name.contains("declare_eow")) { if ((metaTagBits & TagBits.AnnotationForField) != 0) return; } @@ -685,7 +685,7 @@ public class AjProblemReporter extends ProblemReporter { this.delegate = aProblem; // if this was a problem that came via the weaver, it will already have // pinpoint info, don't do it twice... - if (delegate.getMessage().indexOf("message issued...") == -1) { + if (!delegate.getMessage().contains("message issued...")) { this.message = delegate.getMessage() + "\n" + pinpoint; } else { this.message = delegate.getMessage(); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index 219f2fd48..4cd844590 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -579,7 +579,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { lintValue = AjCompilerOptions.ERROR; } else { // Possibly a name=value comma separated list of configurations - if (lintMode.indexOf("=")!=-1) { + if (lintMode.contains("=")) { this.lintMode = AJLINT_DEFAULT; lintOptionsMap = new HashMap(); StringTokenizer tokenizer = new StringTokenizer(lintMode,","); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 98c115190..dfdcba12c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -640,9 +640,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } private boolean acceptResource(String resourceName, boolean fromFile) { - if ((resourceName.startsWith("CVS/")) || (resourceName.indexOf("/CVS/") != -1) || (resourceName.endsWith("/CVS")) + if ((resourceName.startsWith("CVS/")) || (resourceName.contains("/CVS/")) || (resourceName.endsWith("/CVS")) || (resourceName.endsWith(".class")) || (resourceName.startsWith(".svn/")) - || (resourceName.indexOf("/.svn/") != -1) || (resourceName.endsWith("/.svn")) || + || (resourceName.contains("/.svn/")) || (resourceName.endsWith("/.svn")) || // Do not copy manifests if either they are coming from a jar or we are writing to a jar (resourceName.toUpperCase().equals(MANIFEST_NAME) && (!fromFile || zos != null))) { return false; @@ -1382,7 +1382,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } return null; // this is the "OK" return value! } - else if (p.isFile() && p.getName().indexOf("org.aspectj.runtime") != -1) { + else if (p.isFile() && p.getName().contains("org.aspectj.runtime")) { // likely to be a variant from the springsource bundle repo b272591 return null; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java index 833ce2382..7e08c02a7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -1429,7 +1429,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe if (compiledTypes != null) { for (char[] className : (Iterable) compiledTypes.keySet()) { String typeName = new String(className).replace('/', '.'); - if (typeName.indexOf(BcelWeaver.SYNTHETIC_CLASS_POSTFIX) == -1) { + if (!typeName.contains(BcelWeaver.SYNTHETIC_CLASS_POSTFIX)) { ResolvedType rt = world.resolve(typeName); if (rt.isMissing()) { // This can happen in a case where another problem has occurred that prevented it being diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index 77862dddf..776696aff 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -174,7 +174,7 @@ public class AsmElementFormatter { } else if (methodDeclaration instanceof InterTypeDeclaration) { InterTypeDeclaration itd = (InterTypeDeclaration) methodDeclaration; String fqname = itd.getOnType().toString(); - if (fqname.indexOf(".") != -1) { + if (fqname.contains(".")) { // TODO the string handling round here is embarrassing node.addFullyQualifiedName(fqname + "." + new String(itd.getDeclaredSelector())); fqname = fqname.substring(fqname.lastIndexOf(".") + 1); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java index 8a3acaec8..795176c61 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java @@ -161,7 +161,7 @@ public class EclipseAdapterUtils { declared = true; extraDetails = extraDetails.substring(0, extraDetails.length() - "[deow=true]".length()); } - if (extraDetails != null && extraDetails.indexOf("[Xlint:") != -1) { + if (extraDetails != null && extraDetails.contains("[Xlint:")) { isLintMessage = true; lintkey = extraDetails.substring(extraDetails.indexOf("[Xlint:")); lintkey = lintkey.substring("[Xlint:".length()); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java index 6f7a1dd7c..88558fed0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java @@ -570,7 +570,7 @@ public class Main { File file = loc.getSourceFile(); if (null != file) { String name = file.getName(); - if (!toString || (-1 == text.indexOf(name))) { + if (!toString || (!text.contains(name))) { sb.append(FileUtil.getBestPath(file)); if (loc.getLine() > 0) { sb.append(":" + loc.getLine()); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java index 9c504a300..57c2f8e4c 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java @@ -122,7 +122,7 @@ public class AjdtCommandTestCase extends TestCase { public void testIncrementalOption() throws InvalidInputException { AjdtCommand.genBuildConfig(new String[] { "-incremental" }, counter); - assertTrue("didn't specify source root", outputWriter.getContents().indexOf("specify a source root") != -1); + assertTrue("didn't specify source root", outputWriter.getContents().contains("specify a source root")); outputWriter.flushBuffer(); AjdtCommand.genBuildConfig(new String[] { "-incremental", "-sourceroots", Constants.TESTDATA_PATH + "/src1" }, counter); @@ -132,8 +132,7 @@ public class AjdtCommandTestCase extends TestCase { outputWriter.flushBuffer(); AjdtCommand.genBuildConfig(new String[] { "-incremental", "testdata/src1/Hello.java" }, counter); - assertTrue("specified a file", outputWriter.getContents().indexOf( - "incremental mode only handles source files using -sourceroots") != -1); + assertTrue("specified a file", outputWriter.getContents().contains("incremental mode only handles source files using -sourceroots")); } public void testBadOptionAndUsagePrinting() throws InvalidInputException { @@ -143,7 +142,7 @@ public class AjdtCommandTestCase extends TestCase { } // usage printed by caller to genBuildConfig now... assertTrue(outputWriter.getContents() + " contains? " + "Usage", - outputWriter.getContents().indexOf("-mubleBadOption") != -1); + outputWriter.getContents().contains("-mubleBadOption")); } @@ -166,7 +165,7 @@ public class AjdtCommandTestCase extends TestCase { } String text = byteArrayOut.toString(); - assertTrue(text + " contains? " + "Usage", text.indexOf("Usage") != -1); + assertTrue(text + " contains? " + "Usage", text.contains("Usage")); } public void q() throws InvalidInputException { @@ -194,14 +193,13 @@ public class AjdtCommandTestCase extends TestCase { String text = byteArrayOut.toString(); // String text2 = byteArrayErr.toString(); - assertTrue("version output does not include 'AspectJ Compiler', output was:\n'" + text + "'", text - .indexOf("AspectJ Compiler") != -1); + assertTrue("version output does not include 'AspectJ Compiler', output was:\n'" + text + "'", text.contains("AspectJ Compiler")); } public void testNonExistingLstFile() { AjdtCommand.genBuildConfig(new String[] { "@mumbleDoesNotExist" }, counter); - assertTrue(outputWriter.getContents(), outputWriter.getContents().indexOf("file does not exist") != -1); + assertTrue(outputWriter.getContents(), outputWriter.getContents().contains("file does not exist")); } protected void setUp() throws Exception { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java index 1f936661e..c4439c9f7 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java @@ -99,8 +99,8 @@ public class BuildArgParserTestCase extends TestCase { boolean jar2Found = false; for (Object o : cp) { String element = (String) o; - if (element.indexOf("1.jar") != -1) jar1Found = true; - if (element.indexOf("2.jar") != -1) jar2Found = true; + if (element.contains("1.jar")) jar1Found = true; + if (element.contains("2.jar")) jar2Found = true; } assertTrue( config.getClasspath().toString(), @@ -312,7 +312,7 @@ public class BuildArgParserTestCase extends TestCase { "-bootclasspath", PATH }, messageWriter); assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getBootclasspath().toString(), - config.getBootclasspath().get(0).indexOf(PATH) != -1); + config.getBootclasspath().get(0).contains(PATH)); config = genBuildConfig(new String[] { }, @@ -375,8 +375,8 @@ public class BuildArgParserTestCase extends TestCase { boolean jar2Found = false; for (Object o : cp) { String element = (String) o; - if (element.indexOf("1.jar") != -1) jar1Found = true; - if (element.indexOf("2.jar") != -1) jar2Found = true; + if (element.contains("1.jar")) jar1Found = true; + if (element.contains("2.jar")) jar2Found = true; } assertTrue( config.getClasspath().toString(), diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java index dad021a7c..4f40922d6 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java @@ -123,7 +123,7 @@ public class DumpTestCase extends TestCase { String record; while ((null != (record = reader.readLine())) && (result == false)) { if (record.startsWith("----")) currentHeading = record; - else if ((record.indexOf(contents) != -1) && currentHeading.indexOf(heading) != -1) result = true; + else if ((record.contains(contents)) && currentHeading.contains(heading)) result = true; } reader.close(); } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java index 6887d79fe..1dc118283 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java @@ -43,7 +43,7 @@ public class AjBuildManagerTest extends TestCase { final int numMessages = handler.numMessages(IMessage.WARNING, true); if (1 == numMessages) { // permit aspectjrt.jar warning IMessage m = handler.getMessages(IMessage.WARNING, true)[0]; - if (!(m.isWarning() && (-1 != m.getMessage().indexOf("aspectjrt.jar")))) { + if (!(m.isWarning() && (m.getMessage().contains("aspectjrt.jar")))) { assertTrue(handler.toString(), false); } } else if (0 != numMessages) { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index a9442de73..7aa97ad1e 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -224,7 +224,7 @@ public abstract class AjcTestCase extends TestCase { } } if (text != null) { - if (message.getMessage().indexOf(text) == -1) { + if (!message.getMessage().contains(text)) { return false; } } @@ -891,7 +891,7 @@ public abstract class AjcTestCase extends TestCase { private String substituteSandbox(String path) { // the longhand form of the non 1.3 API: path.replace("$sandbox", ajc.getSandboxDirectory().getAbsolutePath()); - while (path.indexOf("$sandbox") != -1) { + while (path.contains("$sandbox")) { int pos = path.indexOf("$sandbox"); String firstbit = path.substring(0, pos); String endbit = path.substring(pos + 8); @@ -918,7 +918,7 @@ public abstract class AjcTestCase extends TestCase { cpIndex = i; args[i + 1] = substituteSandbox(args[i + 1]); String next = args[i + 1]; - hasruntime = ((null != next) && (-1 != next.indexOf("aspectjrt.jar"))); + hasruntime = ((null != next) && (next.contains("aspectjrt.jar"))); } else if ("-p".equals(args[i]) || "--module-path".equals(args[i])) { args[i + 1] = substituteSandbox(args[i + 1]); } @@ -941,7 +941,7 @@ public abstract class AjcTestCase extends TestCase { } boolean needsJRTFS = LangUtil.is19VMOrGreater(); if (needsJRTFS) { - if (args[cpIndex].indexOf(LangUtil.JRT_FS) == -1) { + if (!args[cpIndex].contains(LangUtil.JRT_FS)) { String jrtfsPath = LangUtil.getJrtFsFilePath(); args[cpIndex] = jrtfsPath + File.pathSeparator + args[cpIndex]; } 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/ResolvedMemberImpl.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java index 90fd3ece3..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 @@ -755,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 + ")"); } 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 a5a5eea5d..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 @@ -975,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() { 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/UnresolvedType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java index 155bc0955..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 { @@ -903,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 501ffa418..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 @@ -32,7 +32,7 @@ public class Utils { // 2. there are values specified (i.e. @SuppressAjWarnings("A") or @SuppressAjWarnings({"A","B"}) 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..3b69a5d73 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; } } 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 35f2dc674..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 @@ -212,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); @@ -297,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); 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 3dad2ce6b..39d4a387b 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 @@ -1164,7 +1164,7 @@ public class WildTypePattern extends TypePattern { ret.add(possibleMatch); continue; } - if (possibleMatch.indexOf("$") != -1) { + if (possibleMatch.contains("$")) { names = splitNames(possibleMatch, false); // ??? not most efficient if (namePatterns[0].matches(names[names.length - 1])) { ret.add(possibleMatch); 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/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java index c658bbbd0..b953fa1ce 100644 --- a/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java +++ b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java @@ -40,7 +40,7 @@ public class StringToType { public static Type stringToType(String typeName, Class classScope) throws ClassNotFoundException { try { - if (typeName.indexOf("<") == -1) { + if (!typeName.contains("<")) { return AjTypeSystem.getAjType(Class.forName(typeName,false,classScope.getClassLoader())); } else { return makeParameterizedType(typeName,classScope); diff --git a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java index 542de36d5..9ddb5c0dc 100644 --- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java +++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java @@ -139,8 +139,8 @@ public class AjTypeTest extends TestCase { assertEquals(2,fooTypes.length); // Alex -> Adrian: looks like you can not make assumption on the ordering String s = " " + fooTypes[0].getName() + " " + fooTypes[1].getName(); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$Z") >= 0); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$XX") >= 0); + assertTrue(s.contains(" org.aspectj.internal.lang.reflect.Foo$Z")); + assertTrue(s.contains(" org.aspectj.internal.lang.reflect.Foo$XX")); } public void testGetConstructor() throws Exception { diff --git a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java index a2f33f91b..5431a7457 100644 --- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java +++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java @@ -149,7 +149,7 @@ public class AjTypeWithAspectsTest extends TestCase { for (Method m : ms) { match = match + "--" + m.getName(); } - assertTrue(match.indexOf("aMethod") >=0); + assertTrue(match.contains("aMethod")); } public void testGetDeclaredPointcut() throws Exception { @@ -200,8 +200,8 @@ public class AjTypeWithAspectsTest extends TestCase { assertEquals(2,pcs.length); // AV was corrupted, cannot rely on ordering String match = "simpleAspectMethodExecution--simpleAspectCall"; - assertTrue(match.indexOf(pcs[0].getName()) >= 0); - assertTrue(match.indexOf(pcs[1].getName()) >= 0); + assertTrue(match.contains(pcs[0].getName())); + assertTrue(match.contains(pcs[1].getName())); } public void testGetPointcuts() { diff --git a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java index a908a8ae0..2eb92e97b 100644 --- a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java +++ b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java @@ -69,9 +69,9 @@ public class RuntimeTest extends TestCase { static void checkSoftExceptionString(String s) { - assertTrue(-1 != s.indexOf("SoftException")); - assertTrue(-1 != s.indexOf("Caused by: java.lang.Error")); - assertTrue(-1 != s.indexOf("xyz")); - assertTrue(-1 != s.indexOf("testSoftExceptionPrintStackTrace")); + assertTrue(s.contains("SoftException")); + assertTrue(s.contains("Caused by: java.lang.Error")); + assertTrue(s.contains("xyz")); + assertTrue(s.contains("testSoftExceptionPrintStackTrace")); } } diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java index 9aea9ae6d..84f661cd5 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java @@ -498,7 +498,7 @@ public class Ajc2 extends Javac { } // If there are stars we'll try to resolve the file here - else if (line.indexOf("*") != -1) { + else if (line.contains("*")) { log("The argfile line '" + line + "' is invalid", Project.MSG_WARN); } diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index c68a1eb59..8a7c8a511 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -207,7 +207,7 @@ public class AjcTask extends MatchingTask { int loc = path.lastIndexOf(prefix); if ((-1 != loc) && ((loc + minLength) <= path.length())) { String rest = path.substring(loc + prefixLength); - if (-1 != rest.indexOf(File.pathSeparator)) { + if (rest.contains(File.pathSeparator)) { return null; } if (rest.startsWith(infix) || rest.startsWith(altInfix)) { @@ -827,7 +827,7 @@ public class AjcTask extends MatchingTask { */ public void setInpathDirCopyFilter(String filter) { if (null != filter) { - if (-1 == filter.indexOf("**/*.class")) { + if (!filter.contains("**/*.class")) { filter = "**/*.class," + filter; } } @@ -1344,7 +1344,7 @@ public class AjcTask extends MatchingTask { String message = fail.getMessage(); if (LangUtil.isEmpty(message)) { message = ""; - } else if (-1 != message.indexOf(USAGE_SUBSTRING)) { + } else if (message.contains(USAGE_SUBSTRING)) { continue; } Throwable t = fail.getThrown(); diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java index b1f7c7b4f..4b387c21b 100644 --- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java +++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java @@ -178,7 +178,7 @@ public class AjcTaskTest extends TestCase { String m = e.getMessage(); if (null == m) { assertTrue("not " + exceptionString, false); - } else if (-1 == m.indexOf(exceptionString)) { + } else if (!m.contains(exceptionString)) { assertEquals(exceptionString, e.getMessage()); } } @@ -218,7 +218,7 @@ public class AjcTaskTest extends TestCase { if (NOFILE.equals(input)) { // add nothing } else if (input.endsWith(".lst")) { - if (-1 != input.indexOf(",")) { + if (input.contains(",")) { throw new IllegalArgumentException( "lists not supported: " + input); } else if (null == testdataDir) { @@ -695,7 +695,7 @@ public class AjcTaskTest extends TestCase { } assertTrue( "expecting aspectj in classpath", - (-1 != classpath.indexOf("aspectjrt.jar"))); + (classpath.contains("aspectjrt.jar"))); } CompilerArg createCompilerArg(String value) { @@ -792,7 +792,7 @@ public class AjcTaskTest extends TestCase { boolean matched = false; for (int i = 0; !matched && (i < results.length); i++) { String s = results[i]; - matched = (null != s) && (-1 != s.indexOf(DEFAULT)); + matched = (null != s) && (s.contains(DEFAULT)); } if (!matched) { fail(DEFAULT + " not found in " + Arrays.asList(results)); diff --git a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java index 544e46e2f..5533739a3 100644 --- a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java +++ b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java @@ -190,7 +190,7 @@ public class TesterTest extends TestCase { boolean gotItem(List list, String substring) { for (IMessage element: list) { String s = element.getMessage(); - if ((null != s) && (-1 != s.indexOf(substring))) { + if ((null != s) && (s.contains(substring))) { return true; } } diff --git a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java index e932a027d..6c0a84fe9 100644 --- a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java +++ b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java @@ -1056,7 +1056,7 @@ class SubstringRunner implements StringRunner { input = input.toLowerCase(); } for (String substring : substrings) { - if (-1 != input.indexOf(substring)) { + if (input.contains(substring)) { return true; } } @@ -1150,7 +1150,7 @@ class MessageRunValidator implements IRunValidator { continue; // hmm } String text = message.getMessage(); - if ((null != text) && (-1 != text.indexOf(sought))) { + if ((null != text) && (text.contains(sought))) { return true; } } diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index 6be6cc61e..76b7a181a 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -477,7 +477,7 @@ public final class TestUtil { String[] paths = FileUtil.listFiles(expectedBaseDir); boolean result = true; for (String path : paths) { - if (-1 != path.indexOf("CVS")) { + if (path.contains("CVS")) { continue; } if (!sameFiles(handler, expectedBaseDir, actualBaseDir, path) && result) { diff --git a/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java b/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java index 0807bd2a3..1427ccc8a 100644 --- a/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java +++ b/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java @@ -116,7 +116,7 @@ public class TestUtilTest extends TestCase { } catch (IllegalArgumentException e) { assertTrue("exception: " + errors[i], fail); String m = e.getMessage(); - if (-1 == m.indexOf(errors[i])) { + if (!m.contains(errors[i])) { fail(errors[i] + " not in " + m); } } diff --git a/testing/src/test/java/org/aspectj/testing/AntSpec.java b/testing/src/test/java/org/aspectj/testing/AntSpec.java index 64ff4f364..b5f23ca74 100644 --- a/testing/src/test/java/org/aspectj/testing/AntSpec.java +++ b/testing/src/test/java/org/aspectj/testing/AntSpec.java @@ -208,11 +208,11 @@ public class AntSpec implements ITestStep { if (m_stdErrSpec != null) { String stderr2 = stderr.toString(); // Working around this ridiculous message that still comes out of Java7 builds: - if (stderr2.indexOf("Class JavaLaunchHelper is implemented in both")!=-1 && stderr2.indexOf('\n')!=-1) { + if (stderr2.contains("Class JavaLaunchHelper is implemented in both") && stderr2.indexOf('\n')!=-1) { stderr2 = stderr2.replaceAll("objc\\[[0-9]*\\]: Class JavaLaunchHelper is implemented in both [^\n]*\n",""); } // JDK 11 is complaining about illegal reflective calls - temporary measure ignore these - does that get all tests passing and this is the last problem? - if (stderr2.indexOf("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor") != -1) { + if (stderr2.contains("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor")) { // WARNING: An illegal reflective access operation has occurred // WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor (file:/Users/aclement/gits/org.aspectj/loadtime/bin/) to class java.lang.ClassLoader // WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor diff --git a/testing/src/test/java/org/aspectj/testing/CompileSpec.java b/testing/src/test/java/org/aspectj/testing/CompileSpec.java index 97cba2bc5..e950ee1ba 100644 --- a/testing/src/test/java/org/aspectj/testing/CompileSpec.java +++ b/testing/src/test/java/org/aspectj/testing/CompileSpec.java @@ -68,7 +68,7 @@ public class CompileSpec implements ITestStep { public void setTest(AjcTest t) { this.myTest = t; - if (options != null && (options.indexOf("-1.5") != -1)) { + if (options != null && (options.contains("-1.5"))) { myTest.setVm("1.5"); } } diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index 80e928bc9..d3b064907 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -65,7 +65,7 @@ public class OutputSpec { lineNo++; String outputLine = strTok.nextToken().trim(); /* Avoid trying to match on ajSandbox source names that appear in messages */ - if (outputLine.indexOf(line) == -1) { + if (!outputLine.contains(line)) { matches = false; break; } @@ -88,7 +88,7 @@ public class OutputSpec { found.addAll(outputFound); for (String lineFound : outputFound) { for (String lineExpected : expectedOutputLines) { - if (lineFound.indexOf(lineExpected)!= -1) { + if (lineFound.contains(lineExpected)) { found.remove(lineFound); expected.remove(lineExpected); continue; diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java index cd07733ea..64588ba93 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java @@ -417,7 +417,7 @@ public class AjcTest extends RunSpecIterator { !gotHit && iter.hasNext(); ) { String substring = (String) iter.next(); - if (-1 != this.description.indexOf(substring)) { + if (this.description.contains(substring)) { gotHit = true; } } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java index 12b91679a..abac95dfe 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java @@ -141,7 +141,7 @@ public class CompilerRunSpecTest extends TestCase { } } else { String messages = "" + handler; - if (-1 == messages.indexOf(contains)) { + if (!messages.contains(contains)) { assertTrue(messages, false); } } @@ -398,7 +398,7 @@ public class CompilerRunSpecTest extends TestCase { } if (null != resultContains) { String result = "" + spec.testSetup.commandOptions; - if (-1 == result.indexOf(resultContains)) { + if (!result.contains(resultContains)) { assertTrue( "expected " + resultContains + " got " + result, false); @@ -411,7 +411,7 @@ public class CompilerRunSpecTest extends TestCase { assertTrue("expected " + messagesContain, false); } else { String messages = handler.toString(); - if (-1 == messages.indexOf(messagesContain)) { + if (!messages.contains(messagesContain)) { assertTrue( "expected " + messagesContain diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java index c5f68d03a..9de7642bb 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java @@ -91,7 +91,7 @@ public class CompilerRunTest extends TestCase { String command = (String) dummyReports.remove(0); assertTrue(0 == dummyReports.size()); if ((null == command) - || (-1 == command.indexOf(expectedInCommand))) { + || (!command.contains(expectedInCommand))) { assertTrue("expected " + expectedInCommand + "got " diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index b3249feeb..16d1d6d19 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -162,7 +162,7 @@ public class FlatSuiteReader implements SFileReader.Maker { // so compile succeeds but run not attempted //result.errors = Main.RA_ErrorLine; // result.runOptions = Main.RA_String; - } else if (isNumber(first) || (-1 != first.indexOf(":"))) { + } else if (isNumber(first) || (first.contains(":"))) { exp.addAll(makeMessages(IMessage.ERROR, words, 0, lastFile)); } else { String[] args = new String[words.length - 1]; @@ -275,13 +275,13 @@ public class FlatSuiteReader implements SFileReader.Maker { } input = description.toString(); String error = null; - if (-1 != input.indexOf("&")) { + if (input.contains("&")) { error = "char &"; - } else if (-1 != input.indexOf("<")) { + } else if (input.contains("<")) { error = "char <"; - } else if (-1 != input.indexOf(">")) { + } else if (input.contains(">")) { error = "char >"; - } else if (-1 != input.indexOf("\"")) { + } else if (input.contains("\"")) { error = "char \""; } if (null != error) { diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java index 7aa817f05..db7428816 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java @@ -434,7 +434,7 @@ public class JavaRun implements IAjcRun { protected boolean expectedException(Throwable thrown) { if (null != spec.expectedException) { String cname = thrown.getClass().getName(); - if (-1 != cname.indexOf(spec.expectedException)) { + if (cname.contains(spec.expectedException)) { return true; // caller sets value for returns normally } } @@ -443,7 +443,7 @@ public class JavaRun implements IAjcRun { protected boolean expectedException(ByteArrayOutputStream bout) { return ((null != spec.expectedException) - && (-1 != bout.toString().indexOf(spec.expectedException))); + && (bout.toString().contains(spec.expectedException))); } /** diff --git a/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java b/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java index a6e4c7cab..7013160dc 100644 --- a/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java @@ -134,8 +134,8 @@ public class BridgeUtil { || LangUtil.isEmpty(rhs_s)) { return 0; } - if ((-1 != lhs_s.indexOf(rhs_s)) - || (-1 != rhs_s.indexOf(lhs_s))) { + if ((lhs_s.contains(rhs_s)) + || (rhs_s.contains(lhs_s))) { return 0; } return String.CASE_INSENSITIVE_ORDER.compare(lhs_s, rhs_s); diff --git a/testing/src/test/java/org/aspectj/testing/util/Diffs.java b/testing/src/test/java/org/aspectj/testing/util/Diffs.java index fee19a3e1..f42197873 100644 --- a/testing/src/test/java/org/aspectj/testing/util/Diffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/Diffs.java @@ -438,7 +438,7 @@ public class Diffs { } else if (null == actual) { return false; // expected something } else { - return (-1 != actual.indexOf(expected)); + return (actual.contains(expected)); } } diff --git a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java index a47f694e4..ab780cd29 100644 --- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java @@ -169,7 +169,7 @@ public class FileUtil { String exp = (String) o; if (path.startsWith(exp)) { String suffix = path.substring(exp.length()); - if (-1 == suffix.indexOf("/")) { // normalized... + if (!suffix.contains("/")) { // normalized... expected.remove(path); // found - do not add to unexpected return false; diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java index e78ec84c8..ddf3a832a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java @@ -68,9 +68,9 @@ public class LangUtil { ps = ";"; String cp = System.getProperty("java.class.path"); if (null != cp) { - if (-1 != cp.indexOf(";")) { + if (cp.contains(";")) { ps = ";"; - } else if (-1 != cp.indexOf(":")) { + } else if (cp.contains(":")) { ps = ":"; } // else warn? @@ -105,7 +105,7 @@ public class LangUtil { public static void escape(String input, String target, String escape, StringBuffer sink) { if ((null == sink) || isEmpty(input) || isEmpty(target) || isEmpty(escape)) { return; - } else if (-1 == input.indexOf(target)) { // avoid StringTokenizer construction + } else if (!input.contains(target)) { // avoid StringTokenizer construction sink.append(input); return; } @@ -377,7 +377,7 @@ public class LangUtil { if (isEmpty(input)) { return result; } - if ((!haveDelim) || (-1 == input.indexOf(delim))) { + if ((!haveDelim) || (!input.contains(delim))) { result.add(input); return result; } @@ -482,7 +482,7 @@ public class LangUtil { StringBuffer sb = new StringBuffer(); sb.append(SPLIT_START); for (int i = 0; i < input.length; i++) { - if (-1 != input[i].indexOf(SPLIT_DELIM)) { + if (input[i].contains(SPLIT_DELIM)) { if (null != errs) { errs.append("\nLangUtil.unsplit(..) - item " + i + ": \"" + input[i] + " contains \"" + SPLIT_DELIM + "\""); diff --git a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java index 380766a3b..fd1edaf6f 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java +++ b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java @@ -414,8 +414,8 @@ public class LinkCheck { // only info if redirect from http to https String m = e.getMessage(); if ((m != null) - && (-1 != m.indexOf("protocol")) - && (-1 != m.indexOf("https")) + && (m.contains("protocol")) + && (m.contains("https")) && "http".equals(link.url.getProtocol())) { info("httpsRedirect", link); return; diff --git a/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java b/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java index 8d069af0f..db0e12f5a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java +++ b/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java @@ -98,7 +98,7 @@ public class ValidFileFilter implements FileFilter { if ((null != prefix) && (!(path.startsWith(prefix)))) { return false; } - if ((null != substring) && (-1 == path.indexOf(substring))) { + if ((null != substring) && (!path.contains(substring))) { return false; } if ((null != suffix) && (!(path.endsWith(suffix)))) { diff --git a/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java b/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java index 87748f0b1..79d1ff286 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java @@ -104,7 +104,7 @@ public class OptionChecker { String m = e.getFullMessage(); boolean ok = (null != expectedInExceptionMessage) - && (-1 != m.indexOf(expectedInExceptionMessage)); + && (m.contains(expectedInExceptionMessage)); if (!ok) { e.printStackTrace(System.err); if (null != expectedInExceptionMessage) { @@ -144,7 +144,7 @@ public class OptionChecker { } } else { if ((null == expectedIn) - || (-1 == expectedIn.indexOf(expected))) { + || (!expectedIn.contains(expected))) { assertionFailed( "expected \"" + expected diff --git a/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java b/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java index eaa42326e..7a8b176b7 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java +++ b/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java @@ -132,7 +132,7 @@ public class XMLWriter { printed = true; } String s = o.toString(); - if (-1 != s.indexOf(",")) { + if (s.contains(",")) { throw new IllegalArgumentException("comma in " + s); } sb.append(s); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java index 000a72010..8bc4ad814 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java @@ -88,17 +88,17 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void test016_ByteConversionInstructions() { runTest("RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I"); String output = getLastRunResult().getStdErr(); - assertTrue("Expected to find [b2] in this output but didn't:"+output,output.indexOf("[b2]")!=-1); - assertTrue("Expected to find [b127] in this output but didn't:"+output,output.indexOf("[b127]")!=-1); - assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); + assertTrue("Expected to find [b2] in this output but didn't:"+output, output.contains("[b2]")); + assertTrue("Expected to find [b127] in this output but didn't:"+output, output.contains("[b127]")); + assertTrue("Expected to find [b0] in this output but didn't:"+output, output.contains("[b0]")); - assertTrue("Expected to find [c65] in this output but didn't:"+output,output.indexOf("[c65]")!=-1); - assertTrue("Expected to find [c66] in this output but didn't:"+output,output.indexOf("[c66]")!=-1); - assertTrue("Expected to find [c67] in this output but didn't:"+output,output.indexOf("[c67]")!=-1); + assertTrue("Expected to find [c65] in this output but didn't:"+output, output.contains("[c65]")); + assertTrue("Expected to find [c66] in this output but didn't:"+output, output.contains("[c66]")); + assertTrue("Expected to find [c67] in this output but didn't:"+output, output.contains("[c67]")); - assertTrue("Expected to find [s1] in this output but didn't:"+output,output.indexOf("[s1]")!=-1); - assertTrue("Expected to find [s32767] in this output but didn't:"+output,output.indexOf("[s32767]")!=-1); - assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); + assertTrue("Expected to find [s1] in this output but didn't:"+output, output.contains("[s1]")); + assertTrue("Expected to find [s32767] in this output but didn't:"+output, output.contains("[s32767]")); + assertTrue("Expected to find [b0] in this output but didn't:"+output, output.contains("[b0]")); } public void test017_PrivateMethodCallsInAroundAdvice() { @@ -229,7 +229,7 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("proper handling of ExceptionInIntializer inside clinit in presence of after throwing advice"); String s = getLastRunResult().getStdErr(); assertTrue("Output should contain java.lang.ExceptionInInitializerError but is '"+s+"'", - s.indexOf("java.lang.ExceptionInInitializerError")!=-1); + s.contains("java.lang.ExceptionInInitializerError")); // No getCause on 1.3 JVMs // assertTrue("Output should contain 'CAUSE=org.aspectj.lang.NoAspectBoundException' but is '"+s+"'", // s.indexOf("CAUSE=org.aspectj.lang.NoAspectBoundException")!=-1); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java index c105e881d..8dcb8c34d 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -412,7 +412,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); pw.flush(); String tree = baos.toString(); - assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.indexOf("Red [enumvalue]") != -1); + assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.contains("Red [enumvalue]")); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java index f03ebe3f0..8c277a906 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -243,7 +243,7 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { String[] lines = ls.getLines(); for (int i = 0; i < lines.length; i++) { String existingLine = lines[i]; - if (fileContents[i].indexOf("MethodDeclarationLineNumber") == -1 && !fileContents[i].equals(existingLine)) { + if (!fileContents[i].contains("MethodDeclarationLineNumber") && !fileContents[i].equals(existingLine)) { dump("File contents:", fileContents); dump("Actual:", lines); fail("\nDifference in method " + m.getName() + " on line " + i + " between the expected:\n" + fileContents[i] diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index 5e9e5b25e..b728b8862 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -300,11 +300,11 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { String warning = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"warning\"").getHandleIdentifier(); assertTrue("shouldn't have incremented counter for declare warning handle " + "because only one declare warning statement", - warning.indexOf("!0") == -1 && warning.indexOf("!2") == -1); + !warning.contains("!0") && !warning.contains("!2")); String error = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ERROR, "declare error: \"error\"") .getHandleIdentifier(); assertTrue("shouldn't have incremented counter for declare error handle " + "because only one declare error statement", - error.indexOf("!0") == -1 && error.indexOf("!2") == -1); + !error.contains("!0") && !error.contains("!2")); } // public void testOnlyIncrementSameAdviceKindFromInjar_pr159896() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java index bba565a3a..621c1917c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -143,7 +143,7 @@ public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase { String expected = " messages = ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages(); for (IMessage element : messages) { - if (element.getMessage().indexOf(anError) != -1) { + if (element.getMessage().contains(anError)) { return; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java index 538d2dcbd..3c13ccb71 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -113,7 +113,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. for (UnwovenClassFile ucf: unwovenClassFiles) { - if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + if (!ucf.getFilename().contains(expectedOutputDir)) { fileNames.add(ucf.getFilename()); } } @@ -152,7 +152,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. for (UnwovenClassFile ucf: unwovenClassFiles) { - if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + if (!ucf.getFilename().contains(expectedOutputDir)) { fileNames.add(ucf.getFilename()); } } @@ -182,7 +182,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen List fileNames = new ArrayList<>(); for (UnwovenClassFile ucf: unwovenClassFiles) { - if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + if (!ucf.getFilename().contains(expectedOutputDir)) { fileNames.add(ucf.getFilename()); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 75600dded..c4ea8f120 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -707,7 +707,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // 2 errors are reported when there is a clash - one against the aspect, one against the affected target type. // each of the two errors are recorded against the compilation result for the aspect and the target // So it comes out as 4 - but for now I am tempted to leave it because at least it shows there is a problem... - assertTrue("Was:" + getErrorMessages(p).get(0), getErrorMessages(p).get(0).toString().indexOf("conflicts") != -1); + assertTrue("Was:" + getErrorMessages(p).get(0), getErrorMessages(p).get(0).toString().contains("conflicts")); } public void testOutputLocationCallbacks2() { @@ -789,8 +789,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build(p); checkWasFullBuild(); assertEquals(1, getErrorMessages(p).size()); - assertTrue(((Message) getErrorMessages(p).get(0)).getMessage().indexOf( - "Syntax error on token \")\", \"name pattern\" expected") != -1); + assertTrue(((Message) getErrorMessages(p).get(0)).getMessage().contains("Syntax error on token \")\", \"name pattern\" expected")); } public void testIncrementalMixin() { @@ -1160,15 +1159,15 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject(p); build(p); List l = getErrorMessages(p); - assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); + assertTrue(l.toString().contains("ManagedResource cannot be resolved to a type")); // checkWasFullBuild(); alter(p, "inc1"); build(p); // checkWasntFullBuild(); List compilerErrors = getCompilerErrorMessages(p); - assertTrue(compilerErrors.toString().indexOf("NullPointerException") == -1); + assertTrue(!compilerErrors.toString().contains("NullPointerException")); l = getErrorMessages(p); - assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); + assertTrue(l.toString().contains("ManagedResource cannot be resolved to a type")); } public void testIncrementalAnnoStyle_pr286341() { @@ -1514,13 +1513,13 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa private IProgramElement findFile(IProgramElement whereToLook, String filesubstring) { if (whereToLook.getSourceLocation() != null && whereToLook.getKind().isSourceFile() - && whereToLook.getSourceLocation().getSourceFile().toString().indexOf(filesubstring) != -1) { + && whereToLook.getSourceLocation().getSourceFile().toString().contains(filesubstring)) { return whereToLook; } for (IProgramElement element : whereToLook.getChildren()) { Kind k = element.getKind(); ISourceLocation sloc = element.getSourceLocation(); - if (sloc != null && k.isSourceFile() && sloc.getSourceFile().toString().indexOf(filesubstring) != -1) { + if (sloc != null && k.isSourceFile() && sloc.getSourceFile().toString().contains(filesubstring)) { return element; } if (k.isSourceFile()) { @@ -2961,7 +2960,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List files = getCompiledFiles(projectName); boolean found = false; for (String object: files) { - if (object.indexOf(typeNameSubstring) != -1) { + if (object.contains(typeNameSubstring)) { found = true; } } @@ -3053,7 +3052,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List warnings = getWarningMessages("PR133117"); List noGuardWarnings = new ArrayList<>(); for (IMessage warning: warnings) { - if (warning.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { + if (warning.getMessage().contains("Xlint:noGuardForLazyTjp")) { noGuardWarnings.add(warning); } } @@ -3137,7 +3136,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String decisions = AjdeInteractionTestbed.MyStateListener.getDecisions(); String expect = "Need to recompile 'A.aj'"; assertTrue("Couldn't find build decision: '" + expect + "' in the list of decisions made:\n" + decisions, - decisions.indexOf(expect) != -1); + decisions.contains(expect)); } public void testPr133532_3() { diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java index 333495399..6f6be1256 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java @@ -114,11 +114,11 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA public File getOutputLocationForClass(File compilationUnit) { String relativePath = ""; String compilationUnitName = compilationUnit.getAbsolutePath(); - if (compilationUnitName.indexOf("srcRootOne") != -1) { + if (compilationUnitName.contains("srcRootOne")) { relativePath = "target/main/classes"; - } else if (compilationUnitName.indexOf("srcRootTwo") != -1) { + } else if (compilationUnitName.contains("srcRootTwo")) { relativePath = "target/test/classes"; - } else if (compilationUnitName.indexOf("srcRootThree") != -1) { + } else if (compilationUnitName.contains("srcRootThree")) { relativePath = "target/anotherTest/classes"; } File ret = new File(projectHome, relativePath); diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java index 6e55742b1..1927f47a0 100644 --- a/util/src/main/java/org/aspectj/util/FileUtil.java +++ b/util/src/main/java/org/aspectj/util/FileUtil.java @@ -1404,7 +1404,7 @@ public class FileUtil { /** @return true if input is not null and contains no path separator */ private static boolean isValidFileName(String input) { - return ((null != input) && (-1 == input.indexOf(File.pathSeparator))); + return ((null != input) && (!input.contains(File.pathSeparator))); } private static void listFiles(final File baseDir, String dir, ArrayList result) { diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index a0967cfcc..49a65df52 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -356,7 +356,7 @@ public class LangUtil { } ArrayList result = new ArrayList(); - if (LangUtil.isEmpty(delim) || (-1 == input.indexOf(delim))) { + if (LangUtil.isEmpty(delim) || (!input.contains(delim))) { result.add(input.trim()); } else { StringTokenizer st = new StringTokenizer(input, delim); @@ -1018,7 +1018,7 @@ public class LangUtil { boolean result = false; if (!LangUtil.isEmpty(input)) { for (int i = 0; !result && (i < infixes.length); i++) { - result = (-1 != input.indexOf(infixes[i])); + result = (input.contains(infixes[i])); } } return result; diff --git a/util/src/test/java/org/aspectj/util/FileUtilTest.java b/util/src/test/java/org/aspectj/util/FileUtilTest.java index 367c0ea5e..663352be6 100644 --- a/util/src/test/java/org/aspectj/util/FileUtilTest.java +++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java @@ -162,7 +162,7 @@ public class FileUtilTest extends TestCase { * @param useSuffix if true, then use dir as suffix to path */ private static void doDirPaths(File dir, ArrayList paths) { - if ((null == dir) || !dir.canRead() || (-1 != dir.getPath().indexOf("CVS"))) { + if ((null == dir) || !dir.canRead() || (dir.getPath().contains("CVS"))) { return; } File[] files = dir.listFiles(); diff --git a/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java b/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java index 73a272369..79cd0bbe9 100644 --- a/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java +++ b/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java @@ -189,7 +189,7 @@ public class GenericSignatureParserTest extends TestCase { GenericSignature.FieldTypeSignature cSig = parser.parseAsFieldSignature("Ljava/util/List= 0 && hasIf(pointcut)) { + if (!allowIf && pointcutString.contains("if()") && hasIf(pointcut)) { reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString + "'", struct); return null; } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java index 1eae17682..60f366e5a 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -185,7 +185,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { // TAG: WeavingMessage if (changed && worthReporting && munger != null && !weaver.getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { String tName = weaver.getLazyClassGen().getType().getSourceLocation().getSourceFile().getName(); - if (tName.indexOf("no debug info available") != -1) { + if (tName.contains("no debug info available")) { tName = "no debug info available"; } else { tName = getShortname(weaver.getLazyClassGen().getType().getSourceLocation().getSourceFile().getPath()); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java index 1ee675655..5916e0117 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java @@ -230,7 +230,7 @@ public class BcelWorld extends World implements Repository { */ private String beautifyLocation(ISourceLocation isl) { StringBuffer nice = new StringBuffer(); - if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().indexOf("no debug info available") != -1) { + if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().contains("no debug info available")) { nice.append("no debug info available"); } else { // can't use File.getName() as this fails when a Linux box encounters a path created on Windows and vice-versa @@ -242,7 +242,7 @@ public class BcelWorld extends World implements Repository { if (binary != -1 && binary < takeFrom) { // we have been woven by a binary aspect String pathToBinaryLoc = isl.getSourceFile().getPath().substring(0, binary + 1); - if (pathToBinaryLoc.indexOf(".jar") != -1) { + if (pathToBinaryLoc.contains(".jar")) { // only want to add the extra info if we're from a jar file int lastSlash = pathToBinaryLoc.lastIndexOf('/'); if (lastSlash == -1) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java index 3480b8172..76bd4b84b 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java @@ -71,7 +71,7 @@ public abstract class ExtensibleURLClassLoader extends URLClassLoader { try { unresolvedType = UnresolvedType.forName(name); } catch (BCException bce) { - if (bce.getMessage().indexOf("nameToSignature") == -1) { + if (!bce.getMessage().contains("nameToSignature")) { bce.printStackTrace(System.err); } return null; diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java index bb4a38817..c29721d4a 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java @@ -113,7 +113,7 @@ public class Utility { */ public static String beautifyLocation(ISourceLocation isl) { StringBuffer nice = new StringBuffer(); - if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().indexOf("no debug info available") != -1) { + if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().contains("no debug info available")) { nice.append("no debug info available"); } else { // can't use File.getName() as this fails when a Linux box diff --git a/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java b/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java index 2e8a91291..7df7f438c 100644 --- a/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java +++ b/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java @@ -715,7 +715,7 @@ public class AsmRelationshipProvider { if (kind == ResolvedTypeMunger.Field) { // ITD FIELD // String name = rtMunger.getSignature().toString(); String name = sig.getDeclaringType().getClassName() + "." + sig.getName(); - if (name.indexOf("$") != -1) { + if (name.contains("$")) { name = name.substring(name.indexOf("$") + 1); } IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_FIELD, getBinarySourceLocation( @@ -725,7 +725,7 @@ public class AsmRelationshipProvider { } else if (kind == ResolvedTypeMunger.Method) { // ITD // METHOD String name = sig.getDeclaringType().getClassName() + "." + sig.getName(); - if (name.indexOf("$") != -1) { + if (name.contains("$")) { name = name.substring(name.indexOf("$") + 1); } IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_METHOD, getBinarySourceLocation( @@ -734,7 +734,7 @@ public class AsmRelationshipProvider { return pe; } else if (kind == ResolvedTypeMunger.Constructor) { String name = sig.getDeclaringType().getClassName() + "." + sig.getDeclaringType().getClassName(); - if (name.indexOf("$") != -1) { + if (name.contains("$")) { name = name.substring(name.indexOf("$") + 1); } IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR, diff --git a/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java b/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java index 752473533..ba78b686b 100644 --- a/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java @@ -122,7 +122,7 @@ public class DumpTestCase extends TestCase { String record; while ((null != (record = reader.readLine())) && (result == false)) { if (record.startsWith("----")) currentHeading = record; - else if ((record.indexOf(contents) != -1) && currentHeading.indexOf(heading) != -1) result = true; + else if ((record.contains(contents)) && currentHeading.contains(heading)) result = true; } reader.close(); } diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index 6852da6b7..8e84a71e5 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -125,7 +125,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { String expected = "Type referred to is not an annotation type"; String msg = ((IMessage) mh.messages.get(0)).toString(); - assertTrue("Expected: " + expected + " but got " + msg, msg.indexOf(expected) != -1); + assertTrue("Expected: " + expected + " but got " + msg, msg.contains(expected)); } public void testReferenceViaFormalToNonAnnotationType() { @@ -142,7 +142,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { String expected = "Type referred to is not an annotation type"; String msg = ((IMessage) mh.messages.get(0)).toString(); - assertTrue("Expected: " + expected + " but got " + msg, msg.indexOf(expected) != -1); + assertTrue("Expected: " + expected + " but got " + msg, msg.contains(expected)); // expected = "Binding not supported in @pcds (1.5.0 M1 limitation): null"; // msg = ((IMessage)mh.messages.get(1)).toString(); diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java index ca9835c29..1ea33c465 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java @@ -47,7 +47,7 @@ public class PointcutDesignatorHandlerTest extends TestCase { .parsePointcutExpression("bean(service.*"); fail("should not be able to parse bean(service.*)"); } catch(IllegalArgumentException ex) { - assertTrue("contains bean",ex.getMessage().indexOf("bean") != -1); + assertTrue("contains bean", ex.getMessage().contains("bean")); } } diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java index 9488a5e90..fbf4d3068 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java @@ -336,14 +336,14 @@ public class PointcutParserTest extends TestCase { pc = parser.parsePointcutExpression("args(String)", null, new PointcutParameter[] { param }); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - assertTrue("formal unbound", ex.getMessage().indexOf("formal unbound") != -1); + assertTrue("formal unbound", ex.getMessage().contains("formal unbound")); } try { pc = parser.parsePointcutExpression("args(y)"); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - assertTrue("no match for type name", ex.getMessage().indexOf("warning no match for this type name: y") != -1); + assertTrue("no match for type name", ex.getMessage().contains("warning no match for this type name: y")); } } @@ -357,7 +357,7 @@ public class PointcutParserTest extends TestCase { try { p.parsePointcutExpression("this(FooBar)"); } catch (IllegalArgumentException ex) { - assertTrue("should have xlint:invalidAbsoluteTypeName", ex.getMessage().indexOf("Xlint:invalidAbsoluteTypeName") != -1); + assertTrue("should have xlint:invalidAbsoluteTypeName", ex.getMessage().contains("Xlint:invalidAbsoluteTypeName")); } Properties props = new Properties(); props.put("invalidAbsoluteTypeName", "ignore"); -- cgit v1.2.3 From f33600d4d5507f3aa02d7cacfc34fe910d6b858f Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 8 Aug 2020 03:14:13 +0200 Subject: Unnecessary boxing Reports explicit boxing, i.e. wrapping of primitive values in objects. Explicit manual boxing is unnecessary under Java 5 and newer, and can be safely removed. Signed-off-by: Lars Grefer --- asm/src/main/java/org/aspectj/asm/AsmManager.java | 6 +++--- .../org/aspectj/apache/bcel/classfile/ConstantPool.java | 4 ++-- .../org/aspectj/apache/bcel/generic/Instruction.java | 2 +- .../bridge/context/CompilationAndWeavingContext.java | 4 ++-- .../compiler/lookup/EclipseAnnotationConvertor.java | 2 +- .../org/aspectj/ajdt/internal/core/builder/AjState.java | 2 +- org.aspectj.ajdt.core/src/test/java/AroundAMain.java | 4 ++-- .../ajdt/internal/compiler/batch/IncrementalCase.java | 2 +- .../src/test/java/org/aspectj/tools/ajc/AjAST5Test.java | 6 +++--- .../main/java/org/aspectj/weaver/ResolvedTypeMunger.java | 6 +++--- .../src/main/java/org/aspectj/weaver/Shadow.java | 2 +- .../src/main/java/org/aspectj/weaver/World.java | 2 +- .../org/aspectj/weaver/patterns/ModifiersPattern.java | 5 +++-- .../org/aspectj/weaver/patterns/WildTypePattern.java | 4 ++-- .../java/org/aspectj/weaver/patterns/ArgsTestCase.java | 16 ++++++++-------- .../java/org/aspectj/runtime/internal/Conversions.java | 14 +++++++------- .../org/aspectj/internal/tools/ant/taskdefs/Ajctest.java | 4 ++-- .../java/org/aspectj/testing/harness/bridge/JavaRun.java | 4 ++-- .../test/java/org/aspectj/testing/util/LinkCheck.java | 2 +- .../java/org/aspectj/systemtest/ajc154/Ajc154Tests.java | 2 +- .../org/aspectj/weaver/bcel/AnnotationAccessVar.java | 4 ++-- .../java/org/aspectj/weaver/bcel/BcelClassWeaver.java | 6 +++--- .../main/java/org/aspectj/weaver/bcel/BcelShadow.java | 2 +- .../main/java/org/aspectj/weaver/bcel/LazyMethodGen.java | 4 ++-- .../java/org/aspectj/weaver/tools/cache/SimpleCache.java | 6 +++--- 25 files changed, 58 insertions(+), 57 deletions(-) (limited to 'org.aspectj.matcher') diff --git a/asm/src/main/java/org/aspectj/asm/AsmManager.java b/asm/src/main/java/org/aspectj/asm/AsmManager.java index 6972dda3a..d1b7ed3f2 100644 --- a/asm/src/main/java/org/aspectj/asm/AsmManager.java +++ b/asm/src/main/java/org/aspectj/asm/AsmManager.java @@ -162,7 +162,7 @@ public class AsmManager implements IStructureModel { entries.add(peNode); ISourceLocation sourceLoc = peNode.getSourceLocation(); if (null != sourceLoc) { - Integer hash = new Integer(sourceLoc.getLine()); + Integer hash = sourceLoc.getLine(); List existingEntry = annotations.get(hash); if (existingEntry != null) { entries.addAll(existingEntry); @@ -1189,9 +1189,9 @@ public class AsmManager implements IStructureModel { String node = ipe.getKind().toString(); Integer ctr = nodeTypeCount.get(node); if (ctr == null) { - nodeTypeCount.put(node, new Integer(1)); + nodeTypeCount.put(node, 1); } else { - ctr = new Integer(ctr.intValue() + 1); + ctr = ctr.intValue() + 1; nodeTypeCount.put(node, ctr); } } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java index 0430e28ba..410891212 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java @@ -465,7 +465,7 @@ public class ConstantPool implements Node { String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getValue(); if (!typeSignature.equals(searchSignature)) continue; - fieldCache.put(k, new Integer(i)); + fieldCache.put(k, i); return i; } } @@ -793,7 +793,7 @@ public class ConstantPool implements Node { String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getValue(); if (!typeSignature.equals(searchSignature)) continue; - methodCache.put(key, new Integer(i)); + methodCache.put(key, i); return i; } } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java index 113be06ee..3fa40ac0f 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java @@ -342,7 +342,7 @@ public class Instruction implements Cloneable, Serializable, Constants { case ICONST_3: case ICONST_4: case ICONST_5: - return new Integer(opcode - ICONST_0); + return opcode - ICONST_0; default: throw new IllegalStateException("Not implemented yet for " + getName()); } diff --git a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java index 28a414acd..6117b96a9 100644 --- a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java +++ b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java @@ -123,7 +123,7 @@ public class CompilationAndWeavingContext { } public static void registerFormatter(int phaseId, ContextFormatter aFormatter) { - formatterMap.put(new Integer(phaseId), aFormatter); + formatterMap.put(phaseId, aFormatter); } /** @@ -195,7 +195,7 @@ public class CompilationAndWeavingContext { } private static ContextFormatter getFormatter(ContextStackEntry entry) { - Integer key = new Integer(entry.phaseId); + Integer key = entry.phaseId; if (formatterMap.containsKey(key)) { return formatterMap.get(key); } else { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java index 3d2fb727f..93a5019f3 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java @@ -155,7 +155,7 @@ public class EclipseAnnotationConvertor { Constant c = defaultValue.constant; if (c instanceof IntConstant) { IntConstant iConstant = (IntConstant) c; - return new SimpleAnnotationValue(ElementValue.PRIMITIVE_INT, new Integer(iConstant.intValue())); + return new SimpleAnnotationValue(ElementValue.PRIMITIVE_INT, iConstant.intValue()); } else if (c instanceof BooleanConstant) { BooleanConstant iConstant = (BooleanConstant) c; return new SimpleAnnotationValue(ElementValue.PRIMITIVE_BOOLEAN, iConstant.booleanValue()); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java index 7e08c02a7..4c38f125c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -1536,7 +1536,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe // System.err.println("Detected a structural change in " + thisTime.getFilename()); printStructuralChanges(thisTime.getFilename(),reader, existingStructure); } - structuralChangesSinceLastFullBuild.put(thisTime.getFilename(), new Long(currentBuildTime)); + structuralChangesSinceLastFullBuild.put(thisTime.getFilename(), currentBuildTime); recordTypeChanged(new String(reader.getName()).replace('/', '.')); } } diff --git a/org.aspectj.ajdt.core/src/test/java/AroundAMain.java b/org.aspectj.ajdt.core/src/test/java/AroundAMain.java index d9a2929d0..9dce77d1e 100644 --- a/org.aspectj.ajdt.core/src/test/java/AroundAMain.java +++ b/org.aspectj.ajdt.core/src/test/java/AroundAMain.java @@ -25,7 +25,7 @@ public class AroundAMain {//extends TestCase { @Override public Object run(Object[] args) throws Throwable { // System.out.println("run with: " + Arrays.asList(args)); - return new Integer(10); + return 10; } }; @@ -33,7 +33,7 @@ public class AroundAMain {//extends TestCase { "ajc$perSingletonInstance"); Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$1$73ebb943", // was $AroundA$46 - new Integer(10), true, closure); + 10, true, closure); Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$2$a758212d", // Was $AroundA$c5 "hello there", closure); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java index 6b96c9469..82682bb29 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java @@ -174,7 +174,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? IMessageHolder compilerMessages, StringBuffer commandLine, IMessageHandler handler) { - log("verifyCompile - iteration ", new Integer(iteration), handler); + log("verifyCompile - iteration ", iteration, handler); log("verifyCompile - def ", def, handler); log("verifyCompile - command ", commandLine.toString(), handler); log("verifyCompile - messages ", compilerMessages, handler); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java index c41e07fe1..560d7d244 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java @@ -62,7 +62,7 @@ public class AjAST5Test extends AjASTTestCase { } else if (o instanceof SimplePropertyDescriptor) { SimplePropertyDescriptor element = (SimplePropertyDescriptor) o; if (element.getId().equals("privileged")) { - Boolean b = new Boolean(true); + Boolean b = Boolean.TRUE; d.setStructuralProperty(element, b); assertEquals("AspectDeclaration's isPrivileged property should" + " now be a boolean", b, d.getStructuralProperty(element)); @@ -89,7 +89,7 @@ public class AjAST5Test extends AjASTTestCase { if (o instanceof SimplePropertyDescriptor) { SimplePropertyDescriptor element = (SimplePropertyDescriptor) o; if (element.getId().equals("aspect")) { - Boolean b = new Boolean(true); + Boolean b = Boolean.TRUE; d.setStructuralProperty(element, b); assertEquals("AjTypeDeclaration's aspect property should" + " now be a SignaturePattern", b, d.getStructuralProperty(element)); @@ -140,7 +140,7 @@ public class AjAST5Test extends AjASTTestCase { } else if (o instanceof SimplePropertyDescriptor) { SimplePropertyDescriptor element = (SimplePropertyDescriptor) o; if (element.getId().equals("isExtends")) { - Boolean b = new Boolean(true); + Boolean b = Boolean.TRUE; d.setStructuralProperty(element, b); assertEquals("DeclareParentsDeclaration's isExtends property should" + " now be a boolean", b, d.getStructuralProperty(element)); 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..289547bbc 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 @@ -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 fc2b1d4d1..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 @@ -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)) { 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 3b69a5d73..32648268e 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 @@ -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/ModifiersPattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ModifiersPattern.java index 6c1d0557e..83ad90528 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) { 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 39d4a387b..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 @@ -1023,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 { @@ -1092,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 { 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/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java index 13e8d9edd..6fb5f916f 100644 --- a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java +++ b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java @@ -20,25 +20,25 @@ public final class Conversions { // we might want to keep a cache of small integers around public static Object intObject(int i) { - return new Integer(i); + return i; } public static Object shortObject(short i) { - return new Short(i); + return i; } public static Object byteObject(byte i) { - return new Byte(i); + return i; } public static Object charObject(char i) { - return new Character(i); + return i; } public static Object longObject(long i) { - return new Long(i); + return i; } public static Object floatObject(float i) { - return new Float(i); + return i; } public static Object doubleObject(double i) { - return new Double(i); + return i; } public static Object booleanObject(boolean i) { return i; diff --git a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java index 67e73ed6c..bbe264846 100644 --- a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java +++ b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java @@ -812,7 +812,7 @@ public class Ajctest extends Task implements PropertyChangeListener { List bothargs = new Vector<>(args); bothargs.addAll(testset.args); List> argcombo = argcombo(bothargs); - argcombos.add(new Integer(argcombo.size())); + argcombos.add(argcombo.size()); testsetToArgcombo.put(testset, argcombo); } while (!testsetToArgcombo.isEmpty()) { @@ -1786,7 +1786,7 @@ public class Ajctest extends Task implements PropertyChangeListener { public void add(Failure f, String taskname, String type, int num, long time) { model.addRow(new Object[]{taskname, type, - new Integer(num), date(time)}); + num, date(time)}); failures.add(f); } } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java index db7428816..92aaec667 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java @@ -208,7 +208,7 @@ public class JavaRun implements IAjcRun { } if (thrown instanceof RunSecurityManager.ExitCalledException) { int i = ((RunSecurityManager.ExitCalledException) thrown).exitCode; - status.finish(new Integer(i)); + status.finish(i); } else if (thrown instanceof RunSecurityManager.AwtUsedException) { MessageUtil.fail(status, "test code should not use the AWT event queue"); throw (RunSecurityManager.AwtUsedException) thrown; @@ -224,7 +224,7 @@ public class JavaRun implements IAjcRun { } } catch (RunSecurityManager.ExitCalledException e) { // XXX need to update run validator (a) to accept null result or (b) to require zero result, and set 0 if completed normally - status.finish(new Integer(e.exitCode)); + status.finish(e.exitCode); } catch (ClassNotFoundException e) { String[] classes = FileUtil.listFiles(sandbox.classesDir); MessageUtil.info(status, "sandbox.classes: " + Arrays.asList(classes)); diff --git a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java index fd1edaf6f..d7f6de21a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java +++ b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java @@ -382,7 +382,7 @@ public class LinkCheck { } private void checkingLinks(int i) { - info("checkingLinks", new Integer(i)); + info("checkingLinks", i); } private void checkingLink(Link link) { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java index 6fde74765..ddf37d42a 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java @@ -237,7 +237,7 @@ public class Ajc154Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // Damage the line number table, entry 2 (Line7:5) so it points to an invalid (not on an instruction boundary) position of 6 Field ff = LineNumber.class.getDeclaredField("startPC"); ff.setAccessible(true); - ff.set(oneWeWant.getLineNumberTable().getLineNumberTable()[2], new Integer(6)); + ff.set(oneWeWant.getLineNumberTable().getLineNumberTable()[2], 6); // oneWeWant.getLineNumberTable().getLineNumberTable()[2].setStartPC(6); // Should be 'rounded down' when transforming it into a MethodGen, new position will be '5' diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/AnnotationAccessVar.java b/weaver/src/main/java/org/aspectj/weaver/bcel/AnnotationAccessVar.java index 88a67d666..a6ed94b79 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/AnnotationAccessVar.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/AnnotationAccessVar.java @@ -210,14 +210,14 @@ public class AnnotationAccessVar extends BcelVar { } private void buildArray(InstructionList il, InstructionFactory fact, Type arrayElementType, Type[] arrayEntries, int dim) { - il.append(fact.createConstant(Integer.valueOf(arrayEntries == null ? 0 : arrayEntries.length))); + il.append(fact.createConstant(arrayEntries == null ? 0 : arrayEntries.length)); il.append(fact.createNewArray(arrayElementType, (short) dim)); if (arrayEntries == null) { return; } for (int i = 0; i < arrayEntries.length; i++) { il.append(InstructionFactory.createDup(1)); - il.append(fact.createConstant(Integer.valueOf(i))); + il.append(fact.createConstant(i)); switch (arrayEntries[i].getType()) { case Constants.T_ARRAY: il.append(fact.createConstant(new ObjectType(arrayEntries[i].getSignature()))); // FIXME should be getName() and not diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java index 36cd2686e..2e0b8e5f3 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -1560,7 +1560,7 @@ class BcelClassWeaver implements IClassWeaver { private boolean doesAlreadyHaveAnnotation(ResolvedMember rm, DeclareAnnotation deca, List reportedProblems, boolean reportError) { if (rm.hasAnnotation(deca.getAnnotationType())) { if (reportError && world.getLint().elementAlreadyAnnotated.isEnabled()) { - Integer uniqueID = new Integer(rm.hashCode() * deca.hashCode()); + Integer uniqueID = rm.hashCode() * deca.hashCode(); if (!reportedProblems.contains(uniqueID)) { reportedProblems.add(uniqueID); world.getLint().elementAlreadyAnnotated.signal(new String[] { rm.toString(), @@ -1577,10 +1577,10 @@ class BcelClassWeaver implements IClassWeaver { List reportedProblems) { if (rm != null && rm.hasAnnotation(deca.getAnnotationType())) { if (world.getLint().elementAlreadyAnnotated.isEnabled()) { - Integer uniqueID = new Integer(rm.hashCode() * deca.hashCode()); + Integer uniqueID = rm.hashCode() * deca.hashCode(); if (!reportedProblems.contains(uniqueID)) { reportedProblems.add(uniqueID); - reportedProblems.add(new Integer(itdfieldsig.hashCode() * deca.hashCode())); + reportedProblems.add(itdfieldsig.hashCode() * deca.hashCode()); world.getLint().elementAlreadyAnnotated.signal(new String[] { itdfieldsig.toString(), deca.getAnnotationType().toString() }, rm.getSourceLocation(), new ISourceLocation[] { deca.getSourceLocation() }); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java index e92667b2e..362c8be9d 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java @@ -2942,7 +2942,7 @@ public class BcelShadow extends Shadow { aroundClosureInstance.appendStore(closureInstantiation, fact); // stick the bitflags on the stack and call the variant of linkClosureAndJoinPoint that takes an int - closureInstantiation.append(fact.createConstant(Integer.valueOf(bitflags))); + closureInstantiation.append(fact.createConstant(bitflags)); if (needAroundClosureStacking) { closureInstantiation.append(Utility.createInvoke(getFactory(), getWorld(), new MemberImpl(Member.METHOD, UnresolvedType.forName("org.aspectj.runtime.internal.AroundClosure"), diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java index 049257d48..97f805273 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -1345,11 +1345,11 @@ public final class LazyMethodGen implements Traceable { if (slots == null) { slots = new HashSet(); duplicatedLocalMap.put(start, slots); - } else if (slots.contains(new Integer(tag.getSlot()))) { + } else if (slots.contains(tag.getSlot())) { // we already have a var starting at this tag with this slot continue; } - slots.add(Integer.valueOf(tag.getSlot())); + slots.add(tag.getSlot()); Type t = tag.getRealType(); if (t == null) { t = BcelWorld.makeBcelType(UnresolvedType.forSignature(tag.getType())); diff --git a/weaver/src/main/java/org/aspectj/weaver/tools/cache/SimpleCache.java b/weaver/src/main/java/org/aspectj/weaver/tools/cache/SimpleCache.java index 45d718a14..69cb1a576 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/cache/SimpleCache.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/cache/SimpleCache.java @@ -324,7 +324,7 @@ public class SimpleCache { } defineClassMethod.setAccessible(true); clazz = defineClassMethod.invoke(loader, new Object[] { name, - bytes, new Integer(0), new Integer(bytes.length) }); + bytes, 0, bytes.length}); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof LinkageError) { e.printStackTrace(); @@ -354,8 +354,8 @@ public class SimpleCache { } defineClassWithProtectionDomainMethod.setAccessible(true); clazz = defineClassWithProtectionDomainMethod.invoke(loader, - new Object[] { name, bytes, Integer.valueOf(0), - new Integer(bytes.length), protectionDomain }); + new Object[] { name, bytes, 0, + bytes.length, protectionDomain }); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof LinkageError) { e.printStackTrace(); -- cgit v1.2.3 From 93ce335dc0dad2f420d1b7b1d426ad7bfa3574ad Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 8 Aug 2020 03:16:40 +0200 Subject: Unnecessary unboxing Reports "unboxing", e.g. explicit unwrapping of wrapped primitive values. Unboxing is unnecessary under Java 5 and newer, and can be safely removed. Signed-off-by: Lars Grefer --- asm/src/main/java/org/aspectj/asm/AsmManager.java | 2 +- .../org/aspectj/asm/internal/JDTLikeHandleProvider.java | 12 ++++++------ .../java/org/aspectj/asm/internal/ProgramElement.java | 2 +- .../org/aspectj/apache/bcel/classfile/ConstantPool.java | 4 ++-- .../java/org/aspectj/apache/bcel/generic/FieldGen.java | 8 ++++---- .../org/aspectj/ajdt/internal/core/builder/AjState.java | 4 ++-- .../ajdt/internal/compiler/batch/IncrementalCase.java | 2 +- .../src/test/java/org/aspectj/tools/ajc/AjcTestCase.java | 2 +- .../main/java/org/aspectj/weaver/ResolvedTypeMunger.java | 4 ++-- .../java/org/aspectj/weaver/SimpleAnnotationValue.java | 16 ++++++++-------- .../src/main/java/org/aspectj/weaver/World.java | 2 +- .../org/aspectj/weaver/patterns/ModifiersPattern.java | 2 +- .../main/java/org/aspectj/weaver/tools/TraceFactory.java | 2 +- runtime/src/main/java/org/aspectj/lang/Aspects.java | 6 +++--- runtime/src/main/java/org/aspectj/lang/Aspects14.java | 6 +++--- .../java/org/aspectj/runtime/internal/Conversions.java | 4 ++-- .../aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java | 2 +- .../org/aspectj/tools/ant/taskdefs/compilers/Ajc.java | 10 +++++----- .../test/java/org/aspectj/testing/drivers/Harness.java | 2 +- .../java/org/aspectj/testing/XMLBasedAjcTestCase.java | 2 +- .../org/aspectj/testing/harness/bridge/CompilerRun.java | 2 +- .../org/aspectj/testing/harness/bridge/DirChanges.java | 2 +- .../aspectj/testing/harness/bridge/FlatSuiteReader.java | 2 +- .../aspectj/testing/harness/bridge/ParseTestCase.java | 4 ++-- .../src/test/java/org/aspectj/testing/util/IntRange.java | 2 +- .../java/org/aspectj/testing/util/ObjectChecker.java | 2 +- .../test/java/org/aspectj/testing/xml/SoftMessage.java | 2 +- .../java/org/aspectj/testing/xml/SoftSourceLocation.java | 2 +- .../org/aspectj/systemtest/ajc150/GenericsTests.java | 2 +- util/src/main/java/org/aspectj/util/LangUtil.java | 2 +- 30 files changed, 58 insertions(+), 58 deletions(-) (limited to 'org.aspectj.matcher') diff --git a/asm/src/main/java/org/aspectj/asm/AsmManager.java b/asm/src/main/java/org/aspectj/asm/AsmManager.java index d1b7ed3f2..b8a8989cb 100644 --- a/asm/src/main/java/org/aspectj/asm/AsmManager.java +++ b/asm/src/main/java/org/aspectj/asm/AsmManager.java @@ -1191,7 +1191,7 @@ public class AsmManager implements IStructureModel { if (ctr == null) { nodeTypeCount.put(node, 1); } else { - ctr = ctr.intValue() + 1; + ctr = ctr + 1; nodeTypeCount.put(node, ctr); } } diff --git a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java index 5e518c51f..53818534a 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -172,7 +172,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -228,7 +228,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -280,7 +280,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -315,7 +315,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { int suffixPosition = existingHandle.lastIndexOf('!'); int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384 - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -335,7 +335,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { int suffixPosition = existingHandle.lastIndexOf('!'); int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384 - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -384,7 +384,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; diff --git a/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java b/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java index 77fe7a66b..9842830cb 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java @@ -364,7 +364,7 @@ public class ProgramElement implements IProgramElement { if (b == null) { return false; } - return b.booleanValue(); + return b; } public String[] getRemovedAnnotationTypes() { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java index 410891212..de8f9c650 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java @@ -444,7 +444,7 @@ public class ConstantPool implements Node { String k = new StringBuffer().append(searchClassname).append(searchFieldname).append(searchSignature).toString(); Integer pos = fieldCache.get(k); if (pos != null) - return pos.intValue(); + return pos; for (int i = 1; i < poolSize; i++) { Constant c = pool[i]; if (c != null && c.tag == Constants.CONSTANT_Fieldref) { @@ -771,7 +771,7 @@ public class ConstantPool implements Node { String key = new StringBuffer().append(searchClassname).append(searchMethodName).append(searchSignature).toString(); Integer cached = methodCache.get(key); if (cached != null) - return cached.intValue(); + return cached; searchClassname = searchClassname.replace('.', '/'); for (int i = 1; i < poolSize; i++) { Constant c = pool[i]; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java index 50b9ac496..086f276ee 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java @@ -189,16 +189,16 @@ public class FieldGen extends FieldGenOrMethodGen { case Constants.T_BYTE: case Constants.T_BOOLEAN: case Constants.T_SHORT: - return cp.addInteger(((Integer) value).intValue()); + return cp.addInteger((Integer) value); case Constants.T_FLOAT: - return cp.addFloat(((Float) value).floatValue()); + return cp.addFloat((Float) value); case Constants.T_DOUBLE: - return cp.addDouble(((Double) value).doubleValue()); + return cp.addDouble((Double) value); case Constants.T_LONG: - return cp.addLong(((Long) value).longValue()); + return cp.addLong((Long) value); case Constants.T_REFERENCE: return cp.addString(((String) value)); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java index 4c38f125c..f4518ead3 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -820,7 +820,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe Long l = structuralChangesSinceLastFullBuild.get(file.getAbsolutePath()); long strucModTime = -1; if (l != null) { - strucModTime = l.longValue(); + strucModTime = l; } else { strucModTime = this.lastSuccessfulFullBuildTime; } @@ -837,7 +837,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe for (Map.Entry entry : entries) { Long l = entry.getValue(); if (l != null) { - long lvalue = l.longValue(); + long lvalue = l; if (lvalue > lastSuccessfulBuildTime) { if (listenerDefined()) { getListener().recordDecision( diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java index 82682bb29..9f1162c9f 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java @@ -312,7 +312,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? if (-1 != loc) s = s.substring(loc + 1); try { - exp[i] = Integer.valueOf(s).intValue(); + exp[i] = Integer.valueOf(s); sb.append(exp[i] + ((i < (exp.length - 1)) ? ", " : "")); } catch (NumberFormatException e) { info(handler, "bad " + label + ":" + expected[i]); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index 7aa97ad1e..6bbc076b4 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -1050,7 +1050,7 @@ public abstract class AjcTestCase extends TestCase { private 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); } /* 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 289547bbc..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; 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/World.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java index 32648268e..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 @@ -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 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 83ad90528..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 @@ -97,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/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/runtime/src/main/java/org/aspectj/lang/Aspects.java b/runtime/src/main/java/org/aspectj/lang/Aspects.java index 726b7ed63..ecc388bdb 100644 --- a/runtime/src/main/java/org/aspectj/lang/Aspects.java +++ b/runtime/src/main/java/org/aspectj/lang/Aspects.java @@ -94,7 +94,7 @@ public class Aspects { */ public static boolean hasAspect(Class aspectClass) throws NoAspectBoundException { try { - return ((Boolean)getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY)).booleanValue(); + return (Boolean) getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); } catch (Exception e) { return false; } @@ -108,7 +108,7 @@ public class Aspects { */ public static boolean hasAspect(Class aspectClass, Object perObject) throws NoAspectBoundException { try { - return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); + return (Boolean) getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject}); } catch (Exception e) { return false; } @@ -122,7 +122,7 @@ public class Aspects { */ public static boolean hasAspect(Class aspectClass, Class perTypeWithin) throws NoAspectBoundException { try { - return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); + return (Boolean) getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin}); } catch (Exception e) { return false; } diff --git a/runtime/src/main/java/org/aspectj/lang/Aspects14.java b/runtime/src/main/java/org/aspectj/lang/Aspects14.java index b59374d76..4ddb6b123 100644 --- a/runtime/src/main/java/org/aspectj/lang/Aspects14.java +++ b/runtime/src/main/java/org/aspectj/lang/Aspects14.java @@ -95,7 +95,7 @@ public class Aspects14 { */ public static boolean hasAspect(Class aspectClass) throws NoAspectBoundException { try { - return ((Boolean)getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY)).booleanValue(); + return (Boolean) getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); } catch (Exception e) { return false; } @@ -110,7 +110,7 @@ public class Aspects14 { */ public static boolean hasAspect(Class aspectClass, Object perObject) throws NoAspectBoundException { try { - return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); + return (Boolean) getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject}); } catch (Exception e) { return false; } @@ -125,7 +125,7 @@ public class Aspects14 { */ public static boolean hasAspect(Class aspectClass, Class perTypeWithin) throws NoAspectBoundException { try { - return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); + return (Boolean) getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin}); } catch (Exception e) { return false; } diff --git a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java index 6fb5f916f..0d784266b 100644 --- a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java +++ b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java @@ -112,7 +112,7 @@ public final class Conversions { if (o == null) { return 0; } else if (o instanceof Character) { - return ((Character)o).charValue(); + return (Character) o; } else { throw new ClassCastException(o.getClass().getName() + " can not be converted to char"); @@ -122,7 +122,7 @@ public final class Conversions { if (o == null) { return false; } else if (o instanceof Boolean) { - return ((Boolean)o).booleanValue(); + return (Boolean) o; } else { throw new ClassCastException(o.getClass().getName() + " can not be converted to boolean"); diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java index a64c5131e..d74fa5134 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java @@ -79,7 +79,7 @@ public class Ajc11CompilerAdapter implements CompilerAdapter { if (null == javac) { throw new IllegalStateException("null javac"); } - if (!((Boolean) inSelfCall.get()).booleanValue() + if (!(Boolean) inSelfCall.get() && afterCleaningDirs()) { // if we are not re-calling ourself and we cleaned dirs, // then re-call javac to get the list of all source files. diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java index 0242b4d58..2516a2ac5 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java @@ -91,11 +91,11 @@ public class Ajc extends DefaultCompilerAdapter { Project.MSG_WARN)); System.setOut(logstr); System.setErr(logstr); - return ((Integer)main.getMethod - ("compile", new Class[]{String[].class}).invoke - (main.newInstance(), new Object[]{ - removeUnsupported(cline, logstr) - })).intValue() == AJC_COMPILER_SUCCESS; + return (Integer) main.getMethod + ("compile", new Class[]{String[].class}).invoke + (main.newInstance(), new Object[]{ + removeUnsupported(cline, logstr) + }) == AJC_COMPILER_SUCCESS; } catch (Exception e) { if (e instanceof BuildException) { throw (BuildException)e; diff --git a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java index 6c0a84fe9..55295568a 100644 --- a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java +++ b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java @@ -306,7 +306,7 @@ public class Harness { } Object value = result.status.getResult(); if ((value instanceof Boolean) - && !((Boolean) value).booleanValue()) { + && !(Boolean) value) { System.exit(-1); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java index 0c5b6ddeb..38f85b2c9 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -201,7 +201,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { if (clearTestAfterRun.isEmpty()) { return false; } - boolean result = clearTestAfterRun.peek().booleanValue(); + boolean result = clearTestAfterRun.peek(); if (pop) { clearTestAfterRun.pop(); } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java index 6c8b2ba5f..7a5bff3df 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java @@ -1842,7 +1842,7 @@ public class CompilerRun implements IAjcRun { compilerOption, result); } - return result.booleanValue(); + return result; } } } // CompilerRun.Spec.CRSOptions diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java index 95977aeee..e3e60e028 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java @@ -59,7 +59,7 @@ public class DirChanges { static { long delay = 10l; try { - delay = Long.getLong(DELAY_NAME).longValue(); + delay = Long.getLong(DELAY_NAME); if ((delay > 40000) || (delay < 0)) { delay = 10l; } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index 16d1d6d19..28db821cb 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -267,7 +267,7 @@ public class FlatSuiteReader implements SFileReader.Maker { description.setLength(0); description.append((prefix + " " + suffix).trim()); try { - result.setBugId(Integer.valueOf(pr).intValue()); + result.setBugId(Integer.valueOf(pr)); } catch (NumberFormatException e) { throw new Error("unable to convert " + pr + " for " + result + " at " + lineReader); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java index ee07fe4f6..7aaa1767c 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java @@ -106,7 +106,7 @@ public class ParseTestCase extends TestCase { AjcTest.Spec test = new AjcTest.Spec(); test.setDescription(title); test.setTestDirOffset(dir); - test.setBugId(Integer.valueOf(pr).intValue()); + test.setBugId(Integer.valueOf(pr)); test.setSourceLocation(sourceLocation); //AjcTest test = new AjcTest(title, dir, pr, sourceLocation); @@ -175,7 +175,7 @@ public class ParseTestCase extends TestCase { file = new File("XXX"); //XXX } - int line = Integer.valueOf(getAttributeString(child, "line")).intValue(); + int line = Integer.valueOf(getAttributeString(child, "line")); ISourceLocation sourceLocation = new SourceLocation(file, line, line, 0); diff --git a/testing/src/test/java/org/aspectj/testing/util/IntRange.java b/testing/src/test/java/org/aspectj/testing/util/IntRange.java index 1f44f69bd..4181e7018 100644 --- a/testing/src/test/java/org/aspectj/testing/util/IntRange.java +++ b/testing/src/test/java/org/aspectj/testing/util/IntRange.java @@ -82,7 +82,7 @@ public class IntRange implements IntValidator, ObjectChecker, Serializable { /** @return true if integer instanceof Integer with acceptable intValue */ public final boolean isValid(Object integer) { return ((integer instanceof Integer) - && (acceptInt(((Integer) integer).intValue()))); + && (acceptInt((Integer) integer))); } /** @return true if min <= value < max */ diff --git a/testing/src/test/java/org/aspectj/testing/util/ObjectChecker.java b/testing/src/test/java/org/aspectj/testing/util/ObjectChecker.java index 25985ae5e..e1f771b9d 100644 --- a/testing/src/test/java/org/aspectj/testing/util/ObjectChecker.java +++ b/testing/src/test/java/org/aspectj/testing/util/ObjectChecker.java @@ -34,7 +34,7 @@ public interface ObjectChecker { public static final ObjectChecker ANY_ZERO = new ObjectChecker() { public boolean isValid(Object input) { if (input instanceof Integer) { - return (0 == ((Integer) input).intValue()); + return (0 == (Integer) input); } else { return true; } diff --git a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java index 2241904bd..969c8ecd8 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java +++ b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java @@ -294,7 +294,7 @@ public class SoftMessage implements IMessage { if (null != sourceLocation) { throw new IllegalStateException("cannot set line after creating source location"); } - this.line = Integer.valueOf(line).intValue(); + this.line = Integer.valueOf(line); SourceLocation.validLine(this.line); } diff --git a/testing/src/test/java/org/aspectj/testing/xml/SoftSourceLocation.java b/testing/src/test/java/org/aspectj/testing/xml/SoftSourceLocation.java index 17f5ae673..3895f302e 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/SoftSourceLocation.java +++ b/testing/src/test/java/org/aspectj/testing/xml/SoftSourceLocation.java @@ -109,7 +109,7 @@ public class SoftSourceLocation implements ISourceLocation { } private int convert(String in) { - return Integer.valueOf(in).intValue(); + return Integer.valueOf(in); } public String getLocationContext() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java index 847f67149..76c956965 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -930,7 +930,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { java.lang.reflect.Method isBridge = java.lang.reflect.Method.class.getMethod("isBridge", noparms); Boolean result = (Boolean) isBridge.invoke(m, new Object[0]); - return result.booleanValue(); + return result; } catch (Throwable t) { return false; } diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 49a65df52..ffdc0b66e 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -332,7 +332,7 @@ public class LangUtil { try { String value = System.getProperty(propertyName); if (null != value) { - return Boolean.valueOf(value).booleanValue(); + return Boolean.valueOf(value); } } catch (Throwable t) { // default below -- cgit v1.2.3