diff options
Diffstat (limited to 'org.aspectj.matcher')
14 files changed, 24 insertions, 35 deletions
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 2d969c2f8..763f78f0b 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 @@ -13,6 +13,7 @@ package org.aspectj.weaver; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.aspectj.bridge.ISourceLocation; @@ -135,15 +136,11 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele AbstractReferenceTypeDelegate outerObjectType = (AbstractReferenceTypeDelegate) outerDelegate; if (outerObjectType.isNested()) { GenericSignature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass(); - for (GenericSignature.FormalTypeParameter parentParam : parentParams) { - typeParameters.add(parentParam); - } + Collections.addAll(typeParameters, parentParams); } GenericSignature.ClassSignature outerSig = outerObjectType.getGenericClassTypeSignature(); if (outerSig != null) { - for (FormalTypeParameter formalTypeParameter : outerSig.formalTypeParameters) { - typeParameters.add(formalTypeParameter); - } + Collections.addAll(typeParameters, outerSig.formalTypeParameters); } GenericSignature.FormalTypeParameter[] ret = new GenericSignature.FormalTypeParameter[typeParameters.size()]; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java index cd786e724..d759bc721 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java @@ -304,9 +304,7 @@ public abstract class Advice extends ShadowMunger { return allNames; } String[] result = new String[getBaseParameterCount()]; - for (int i = 0; i < result.length; i++) { - result[i] = allNames[i]; - } + if (result.length >= 0) System.arraycopy(allNames, 0, result, 0, result.length); return result; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java index c3f22b0b1..e71850c05 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java @@ -74,8 +74,8 @@ public class CrosscuttingMembers { this.shouldConcretizeIfNeeded = shouldConcretizeIfNeeded; } - private final Hashtable<String, Object> cflowFields = new Hashtable<>(); - private final Hashtable<String, Object> cflowBelowFields = new Hashtable<>(); + private final Map<String, Object> cflowFields = new Hashtable<>(); + private final Map<String, Object> cflowBelowFields = new Hashtable<>(); // public void addConcreteShadowMungers(Collection c) { // shadowMungers.addAll(c); @@ -293,8 +293,7 @@ public class CrosscuttingMembers { theseShadowMungers.add(munger); } } - Set<ShadowMunger> tempSet = new HashSet<>(); - tempSet.addAll(other.shadowMungers); + Set<ShadowMunger> tempSet = new HashSet<>(other.shadowMungers); Set<ShadowMunger> otherShadowMungers = new HashSet<>(); Set<ShadowMunger> otherInlinedAroundMungers = new HashSet<>(); for (ShadowMunger munger : tempSet) { 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 86caa48c5..d7bd742b8 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 @@ -211,7 +211,7 @@ public class MemberImpl implements Member { l.add(UnresolvedType.forSignature(sig.substring(start, i))); } } - UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[l.size()]); + UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[0]); UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length())); return new Object[] { returnType, paramTypes }; } else { 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 3d88279af..9a322d98f 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 @@ -1082,7 +1082,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl l.add(m); } } - return l.toArray(new ResolvedMember[l.size()]); + return l.toArray(new ResolvedMember[0]); } public abstract ISourceContext getSourceContext(); @@ -1425,13 +1425,13 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl * ??? This method is O(N*M) where N = number of methods and M is number of inter-type declarations in my super */ public List<ConcreteTypeMunger> getInterTypeMungersIncludingSupers() { - ArrayList<ConcreteTypeMunger> ret = new ArrayList<>(); + List<ConcreteTypeMunger> ret = new ArrayList<>(); collectInterTypeMungers(ret); return ret; } public List<ConcreteTypeMunger> getInterTypeParentMungersIncludingSupers() { - ArrayList<ConcreteTypeMunger> ret = new ArrayList<>(); + List<ConcreteTypeMunger> ret = new ArrayList<>(); collectInterTypeParentMungers(ret); return ret; } 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 2cc737347..f906a397e 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 @@ -50,7 +50,7 @@ public class AnnotationPatternList extends PatternNode { } public AnnotationPatternList(List<AnnotationTypePattern> l) { - this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[l.size()])); + this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[0])); } protected AnnotationTypePattern[] getAnnotationPatterns() { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java index ef537d807..15713e76d 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java @@ -160,7 +160,7 @@ public class BasicTokenSource implements ITokenSource { //System.out.println(tokens); - return new BasicTokenSource((IToken[])tokens.toArray(new IToken[tokens.size()]), context); + return new BasicTokenSource((IToken[])tokens.toArray(new IToken[0]), context); } private static String makeString(char ch) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java index 8c2cb36b9..4e614824a 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java @@ -308,7 +308,7 @@ public class IfPointcut extends Pointcut { } } - ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[]) args.toArray(new Expr[args.size()]))); + ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[]) args.toArray(new Expr[0]))); // Remember... ifLastMatchedShadowId = shadow.shadowId; 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 4e1ef74df..c0fed9aee 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 @@ -252,9 +252,7 @@ public class PointcutRewriter { } // otherwise ... Pointcut[] subset = new Pointcut[ps.length - 1]; - for (int i = 1; i < ps.length; i++) { - subset[i - 1] = ps[i]; - } + if (ps.length - 1 >= 0) System.arraycopy(ps, 1, subset, 0, ps.length - 1); return new AndPointcut(ps[0], createAndsFor(subset)); } 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 2b17520a2..fdbc40d12 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 @@ -59,7 +59,7 @@ public class TypePatternList extends PatternNode { } public TypePatternList(List<TypePattern> l) { - this((TypePattern[]) l.toArray(new TypePattern[l.size()])); + this((TypePattern[]) l.toArray(new TypePattern[0])); } public int size() { 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 b8e58c342..b8c4ac31b 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 @@ -110,7 +110,7 @@ public class WildTypePattern extends TypePattern { } public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim) { - this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, false, TypePatternList.EMPTY); + this((NamePattern[]) names.toArray(new NamePattern[0]), includeSubtypes, dim, false, TypePatternList.EMPTY); } @@ -127,7 +127,7 @@ public class WildTypePattern extends TypePattern { public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams, TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound) { - this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, isVarArg, typeParams); + this((NamePattern[]) names.toArray(new NamePattern[0]), includeSubtypes, dim, isVarArg, typeParams); this.end = endPos; this.upperBound = upperBound; this.lowerBound = lowerBound; @@ -135,7 +135,7 @@ public class WildTypePattern extends TypePattern { } public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams) { - this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, isVarArg, typeParams); + this((NamePattern[]) names.toArray(new NamePattern[0]), includeSubtypes, dim, isVarArg, typeParams); this.end = endPos; } @@ -588,9 +588,7 @@ public class WildTypePattern extends TypePattern { @Override public TypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { NamePattern[] newNamePatterns = new NamePattern[namePatterns.length]; - for (int i = 0; i < namePatterns.length; i++) { - newNamePatterns[i] = namePatterns[i]; - } + System.arraycopy(namePatterns, 0, newNamePatterns, 0, namePatterns.length); if (newNamePatterns.length == 1) { String simpleName = newNamePatterns[0].maybeGetSimpleName(); if (simpleName != null) { @@ -1171,7 +1169,7 @@ public class WildTypePattern extends TypePattern { } } } - return ret.toArray(new String[ret.size()]); + return ret.toArray(new String[0]); } // public void postRead(ResolvedType enclosingType) { 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 9389fff8b..613437346 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 @@ -189,7 +189,7 @@ public abstract class CommonWorldTests extends TestCase { protected void mungersTest(ResolvedType ty, ShadowMunger[] x) { List<ShadowMunger> l = ty.getDeclaredShadowMungers(); - ShadowMunger[] array = (ShadowMunger[]) l.toArray(new ShadowMunger[l.size()]); + ShadowMunger[] array = (ShadowMunger[]) l.toArray(new ShadowMunger[0]); TestUtil.assertSetEquals(ty + " mungers:", x, array); } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java index 9f7daa756..69bc674ef 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java @@ -298,7 +298,7 @@ public class TestUtils { l.add(str.substring(start, i).trim()); start = i + 1; } - return (String[]) l.toArray(new String[l.size()]); + return (String[]) l.toArray(new String[0]); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java index 9f524d836..f3609b7d7 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java @@ -700,8 +700,7 @@ public class ParserTestCase extends PatternsTestCase { WildAnnotationTypePattern watp = (WildAnnotationTypePattern) atp; Map<String,String> m = watp.annotationValues; Set<String> keys = m.keySet(); - List<String> orderedKeys = new ArrayList<>(); - orderedKeys.addAll(keys); + List<String> orderedKeys = new ArrayList<>(keys); Collections.sort(orderedKeys); StringBuffer sb = new StringBuffer(); for (Iterator<String> iterator = orderedKeys.iterator(); iterator.hasNext();) { |