diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 16:33:00 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 16:36:00 +0200 |
commit | 2409bcbc7c9606b055e23f52d688eecda84351d6 (patch) | |
tree | e775e9d0e033ec563236c31623f66d023c40aac5 | |
parent | 3641f1626df6b9b1c11dd3f16b01a01495f4662d (diff) | |
download | aspectj-2409bcbc7c9606b055e23f52d688eecda84351d6.tar.gz aspectj-2409bcbc7c9606b055e23f52d688eecda84351d6.zip |
Redundant Collection.addAll() call
Reports Collection.addAll() and Map.putAll() calls after instantiation of a collection using a constructor call without arguments. Such constructs can be replaced with a single call to a parametrized constructor which simplifies code. Also for some collections the replacement might be more performant.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
28 files changed, 41 insertions, 78 deletions
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 a8b82ce7f..7aec20809 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 @@ -225,8 +225,7 @@ public class AjdeCoreBuildManager { if (projectSourceFiles == null) { return null; } - List<String> l = new ArrayList<>(); - l.addAll(projectSourceFiles); + List<String> l = new ArrayList<>(projectSourceFiles); // If the processor options are specified build the command line options for the JDT compiler to see String processor = compilerConfig.getProcessor(); if (processor != null && processor.length() != 0) { diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java index c5fa43e16..13597f14f 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java @@ -367,8 +367,7 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { String line = null; while ((line = fr.readLine()) != null) fileContents.add(line); - List<String> originalFileContents = new ArrayList<>(); - originalFileContents.addAll(fileContents); + List<String> originalFileContents = new ArrayList<>(fileContents); // See if the messages match int msgCount = 0; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java index c5c244869..8c9c65ab7 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java @@ -170,8 +170,7 @@ public class InstructionHandle implements java.io.Serializable { } public Set<InstructionTargeter> getTargetersCopy() { - Set<InstructionTargeter> copy = new HashSet<>(); - copy.addAll(targeters); + Set<InstructionTargeter> copy = new HashSet<>(targeters); return copy; } 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 ed64e74e0..5d592243c 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 @@ -469,8 +469,7 @@ class HeaderInfo { this.lastLine = lastLine; this.file = file; this.hasLicense = hasLicense; - List<String> newYears = new ArrayList<>(); - newYears.addAll(years); + List<String> newYears = new ArrayList<>(years); Collections.sort(newYears); this.years = Collections.unmodifiableList(newYears); if ((null == file) || !file.canWrite()) { diff --git a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java index 86782563f..bf9b9aab9 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java @@ -419,8 +419,7 @@ class Samples { } List<Sample> getSortedSamples(Comparator<Sample> comparer) { - ArrayList<Sample> result = new ArrayList<>(); - result.addAll(samples); + ArrayList<Sample> result = new ArrayList<>(samples); result.sort(comparer); return result; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java index a68698697..c309a3a5a 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -152,8 +152,7 @@ public class BuildArgParser extends Main { boolean incrementalMode = buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode(); - List<File> xmlfileList = new ArrayList<>(); - xmlfileList.addAll(parser.getXmlFiles()); + List<File> xmlfileList = new ArrayList<>(parser.getXmlFiles()); List<File> fileList = new ArrayList<>(); List<File> files = parser.getFiles(); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index 809a73af8..beea71dc9 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -250,8 +250,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC Collections.addAll(typesToProcess, stbs); } - List<SourceTypeBinding> stb2 = new ArrayList<>(); - stb2.addAll(typesToProcess); + List<SourceTypeBinding> stb2 = new ArrayList<>(typesToProcess); while (typesToProcess.size() > 0) { // A side effect of weaveIntertypes() is that the processed type is removed from the collection 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 cfda72357..4fb176e88 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 @@ -377,8 +377,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { * classpath), and output dir or jar */ public List<String> getFullClasspath() { - List<String> full = new ArrayList<>(); - full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? + List<String> full = new ArrayList<>(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? for (File file: inJars) { full.add(file.getAbsolutePath()); } 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 355267b0f..09ecdb34b 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 @@ -121,8 +121,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? List safeFiles = Collections.unmodifiableList(files); log("Compiling ", safeFiles, handler); if (1 == i) { - ArrayList<String> argList = new ArrayList<>(); - argList.addAll(getBaseArgs(targetSrc, targetClasses)); + ArrayList<String> argList = new ArrayList<>(getBaseArgs(targetSrc, targetClasses)); File[] fra = (File[]) safeFiles.toArray(new File[0]); // sigh argList.addAll( 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..d380e988e 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 @@ -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/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();) { 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 83dcd9911..c6ebb14b3 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 @@ -1159,7 +1159,6 @@ public class AjcTask extends MatchingTask { // package-private for testing String[] makeCommand() { - ArrayList result = new ArrayList(); if (0 < ignored.size()) { for (Object o : ignored) { logVerbose("ignored: " + o); @@ -1182,7 +1181,7 @@ public class AjcTask extends MatchingTask { outjarFixedup = true; } - result.addAll(cmd.extractArguments()); + ArrayList result = new ArrayList(cmd.extractArguments()); addListArgs(result); String[] command = (String[]) result.toArray(new String[0]); 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 25128bb61..43125a862 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 @@ -53,8 +53,7 @@ public class Ajc extends DefaultCompilerAdapter { "-encoding", "-target" }); private static List<String> finalList(String[] args) { - List<String> result = new ArrayList<>(); - result.addAll(Arrays.asList(args)); + List<String> result = new ArrayList<>(Arrays.asList(args)); return Collections.unmodifiableList(result); } 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 55295568a..42f4c4451 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 @@ -213,8 +213,7 @@ public class Harness { // read arguments final ArrayList<String> globals = new ArrayList<>(); final ArrayList<String> files = new ArrayList<>(); - final LinkedList<String> argList = new LinkedList<>(); - argList.addAll(Arrays.asList(args)); + final LinkedList<String> argList = new LinkedList<>(Arrays.asList(args)); for (int i = 0; i < argList.size(); i++) { String arg = argList.get(i); List<String> aliases = aliasOptions(arg); diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index ca7d0f232..8e1fd2612 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -87,10 +87,8 @@ public class OutputSpec { createFailureMessage(output, -1, outputFound.size()); return; } - List<String> expected = new ArrayList<>(); - expected.addAll(expectedOutputLines); - List<String> found = new ArrayList<>(); - found.addAll(outputFound); + List<String> expected = new ArrayList<>(expectedOutputLines); + List<String> found = new ArrayList<>(outputFound); for (String lineFound : outputFound) { for (String lineExpected : expectedOutputLines) { if (lineFound.contains(lineExpected)) { 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 ea88c49f1..acc3245ca 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 @@ -167,8 +167,7 @@ public class JavaRun implements IAjcRun { File[] files = sandbox.findFiles(spec.aspectpath); aspectURLs = FileUtil.getFileURLs(files); } - ArrayList classpath = new ArrayList(); - classpath.addAll(Arrays.asList(aspectURLs)); + ArrayList classpath = new ArrayList(Arrays.asList(aspectURLs)); final URL[] classURLs; { classpath.addAll(Arrays.asList(clAndLibs)); 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 ab780cd29..71dfb7f2e 100644 --- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java @@ -185,9 +185,8 @@ public class FileUtil { // skip if not file or not right time return false; } - }; - ArrayList unexp = new ArrayList(); - unexp.addAll(Arrays.asList(dir.listFiles(touchedCollector))); + }; + ArrayList unexp = new ArrayList(Arrays.asList(dir.listFiles(touchedCollector))); // report any unexpected changes return Diffs.makeDiffs(label, expected, unexp, String.CASE_INSENSITIVE_ORDER); 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 23385db3a..ad9331dd3 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java @@ -402,8 +402,7 @@ public class LangUtil { * @see Util#combine(Object[], Object[]) */ public static String[] combine(String[] one, String[] two) { - ArrayList twoList = new ArrayList(); - twoList.addAll(org.aspectj.util.LangUtil.arrayAsList(two)); + ArrayList twoList = new ArrayList(org.aspectj.util.LangUtil.arrayAsList(two)); ArrayList result = new ArrayList(); if (null != one) { for (String s : one) { @@ -938,13 +937,11 @@ public class LangUtil { if ((0 == actualListIn.size()) && (0 == expectedListIn.size()) ) { return; } - - ArrayList expected = new ArrayList(); - expected.addAll(expectedListIn); + + ArrayList expected = new ArrayList(expectedListIn); expected.sort(comparator); - - ArrayList actual = new ArrayList(); - actual.addAll(actualListIn); + + ArrayList actual = new ArrayList(actualListIn); actual.sort(comparator); Iterator actualIter = actual.iterator(); Object act = null; diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java index 30f2a0b06..6eede56a6 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java @@ -269,8 +269,7 @@ public class LangUtilTest extends TestCase { if (unmodifiable) { return Collections.unmodifiableList(Arrays.asList(ra)); } else { - ArrayList list = new ArrayList(); - list.addAll(Arrays.asList(ra)); + ArrayList list = new ArrayList(Arrays.asList(ra)); return list; } } @@ -317,8 +316,7 @@ public class LangUtilTest extends TestCase { String label = one + "?=" + two; assertTrue(label, (null == one) == (null == two)); if (null != one) { - ArrayList aone = new ArrayList(); - aone.addAll(one); + ArrayList aone = new ArrayList(one); ArrayList atwo = new ArrayList(); aone.addAll(two); Collections.sort(aone); diff --git a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java index 954ab38c0..abfff1ee6 100644 --- a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java @@ -71,9 +71,8 @@ public class MessageUtilTest extends TestCase { List getSampleMessageTexts() { if (null == messageTexts) { - ArrayList result = new ArrayList(); - result.addAll(Arrays.asList(new String[] - { "one", "two", "now is the time for all good men..." })); + ArrayList result = new ArrayList(Arrays.asList(new String[] + {"one", "two", "now is the time for all good men..."})); messageTexts = result; } return messageTexts; diff --git a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java index dbb0c1bb1..11dd15587 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java @@ -141,8 +141,7 @@ public class TestDiffs { // XXX pretty dumb implementation * @return ArrayList with all input except those in trim (by name) */ private static ArrayList trimByName(List input, List trim) { - ArrayList result = new ArrayList(); - result.addAll(input); + ArrayList result = new ArrayList(input); if (!LangUtil.isEmpty(input) && !LangUtil.isEmpty(trim)) { for (ListIterator iter = result.listIterator(); iter.hasNext();) { TestResult inputItem = (TestResult) iter.next(); @@ -281,8 +280,7 @@ public class TestDiffs { // XXX pretty dumb implementation actualFailed = safeList(failed); // stillPassing: expected.passed w/o broken, missingPasses - passed = new ArrayList(); - passed.addAll(expectedPassed); + passed = new ArrayList(expectedPassed); passed = trimByName(passed, this.broken); ArrayList missingPasses = new ArrayList(); ArrayList missingFails = new ArrayList(); @@ -291,8 +289,7 @@ public class TestDiffs { // XXX pretty dumb implementation stillPassing = safeList(passed); // stillFailing: expected.failed w/o fixed, missingFails - failed = new ArrayList(); - failed.addAll(expectedFailed); + failed = new ArrayList(expectedFailed); failed = trimByName(failed, this.fixed); failed = trimByName(failed, missingFails); stillFailing = safeList(failed); diff --git a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java index b18d9a5f7..550ff759a 100644 --- a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java +++ b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java @@ -143,8 +143,7 @@ public abstract class ModelTestCase extends XMLBasedAjcTestCase { while ((expectedLine = expect.readLine()) != null) { fileContents.add(expectedLine); } - List<String> expectedFileContents = new ArrayList<>(); - expectedFileContents.addAll(fileContents); + List<String> expectedFileContents = new ArrayList<>(fileContents); // Load the file with the output from this test run BufferedReader found = new BufferedReader(new FileReader(new File(modelOutput))); diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 98f53e3c8..e97438b0e 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -1000,8 +1000,7 @@ public class LangUtil { if ((null == array) || (1 > array.length)) { return Collections.emptyList(); } - ArrayList<T> list = new ArrayList<>(); - list.addAll(Arrays.asList(array)); + ArrayList<T> list = new ArrayList<>(Arrays.asList(array)); return list; } diff --git a/util/src/test/java/org/aspectj/util/FileUtilTest.java b/util/src/test/java/org/aspectj/util/FileUtilTest.java index 7936914fb..f5466e2cf 100644 --- a/util/src/test/java/org/aspectj/util/FileUtilTest.java +++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java @@ -508,8 +508,7 @@ public class FileUtilTest extends TestCase { errors.add(error); } }; - List<String> sourceList = new ArrayList<>(); - sourceList.addAll(Arrays.asList(sources)); + List<String> sourceList = new ArrayList<>(Arrays.asList(sources)); sourceList = Collections.unmodifiableList(sourceList); for (int k = 0; k < sources.length; k++) { List<String> result = FileUtil.lineSeek("" + k, sourceList, true, errorSink); 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 06735b523..edf7a0c48 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -923,8 +923,7 @@ class BcelClassWeaver implements IClassWeaver { return false; // nothing to do } - Set<DeclareAnnotation> unusedDecams = new HashSet<>(); - unusedDecams.addAll(decaMs); + Set<DeclareAnnotation> unusedDecams = new HashSet<>(decaMs); // These methods may have been targeted with declare annotation. Example: ITD on an interface // where the top most implementor gets a real method. The top most implementor method @@ -1413,8 +1412,7 @@ class BcelClassWeaver implements IClassWeaver { List<BcelField> fields = clazz.getFieldGens(); if (fields != null) { - Set<DeclareAnnotation> unusedDecafs = new HashSet<>(); - unusedDecafs.addAll(decafs); + Set<DeclareAnnotation> unusedDecafs = new HashSet<>(decafs); for (BcelField field : fields) { if (!field.getName().startsWith(NameMangler.PREFIX)) { // Single first pass diff --git a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java index 2c99ee29f..f9b020272 100644 --- a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java @@ -599,8 +599,7 @@ public class ReferenceTypeTestCase extends TestCase { // ReferenceType.r = 0; long stime = System.nanoTime(); for (int j = 0; j < 10; j++) { - List objects2 = new ArrayList(); - objects2.addAll(objects); + List objects2 = new ArrayList(objects); PartialOrder.sort(objects2); } long etime = System.nanoTime(); diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java index a9d1fe9b4..ea5037e2c 100644 --- a/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java @@ -80,12 +80,10 @@ public class AroundWeaveTestCase extends WeaveTestCase { private void aroundTestAndOthers(String outName, final boolean matchOnlyPrintln) throws IOException { - - List<ShadowMunger> l = new ArrayList<>(); - // the afterReturning was taken out to avoid circular advice dependency + // the afterReturning was taken out to avoid circular advice dependency - l.addAll(makeAdviceAll("before", matchOnlyPrintln)); + List<ShadowMunger> l = new ArrayList<>(makeAdviceAll("before", matchOnlyPrintln)); //l.addAll(makeAdviceAll("afterReturning", matchOnlyPrintln)); l.add(makeAroundMunger(matchOnlyPrintln)); diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java index 5181efcf6..ab15c2bd3 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java @@ -286,8 +286,7 @@ public class Java15PointcutExpressionTest extends TestCase { tps[parameterNumber].getAnnotationPattern().toString(); // parameter type annotation checking - Set<String> expected = new HashSet<>(); - expected.addAll(mpnv.getParameterTypeAnnotations()); + Set<String> expected = new HashSet<>(mpnv.getParameterTypeAnnotations()); StringTokenizer st = new StringTokenizer(expectedParameterTypeAnnotations==null?"":expectedParameterTypeAnnotations); while (st.hasMoreTokens()) { @@ -305,8 +304,7 @@ public class Java15PointcutExpressionTest extends TestCase { } // parameter annotation checking - expected = new HashSet<>(); - expected.addAll(mpnv.getParameterAnnotations()); + expected = new HashSet<>(mpnv.getParameterAnnotations()); st = new StringTokenizer(expectedParameterAnnotations==null?"":expectedParameterAnnotations); while (st.hasMoreTokens()) { |