From 2409bcbc7c9606b055e23f52d688eecda84351d6 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 15 Aug 2020 16:33:00 +0200 Subject: 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 --- .../aspectj/ajde/core/internal/AjdeCoreBuildManager.java | 3 +-- .../org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java | 3 +-- .../org/aspectj/apache/bcel/generic/InstructionHandle.java | 3 +-- .../org/aspectj/internal/tools/ant/taskdefs/Checklics.java | 3 +-- .../org/aspectj/internal/tools/build/SampleGatherer.java | 3 +-- .../src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java | 3 +-- .../ajdt/internal/compiler/lookup/AjLookupEnvironment.java | 3 +-- .../aspectj/ajdt/internal/core/builder/AjBuildConfig.java | 3 +-- .../ajdt/internal/compiler/batch/IncrementalCase.java | 3 +-- .../main/java/org/aspectj/weaver/CrosscuttingMembers.java | 3 +-- .../java/org/aspectj/weaver/patterns/ParserTestCase.java | 3 +-- .../main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java | 3 +-- .../java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java | 3 +-- .../src/test/java/org/aspectj/testing/drivers/Harness.java | 3 +-- testing/src/test/java/org/aspectj/testing/OutputSpec.java | 6 ++---- .../java/org/aspectj/testing/harness/bridge/JavaRun.java | 3 +-- .../src/test/java/org/aspectj/testing/util/FileUtil.java | 5 ++--- .../src/test/java/org/aspectj/testing/util/LangUtil.java | 13 +++++-------- .../test/java/org/aspectj/testing/util/LangUtilTest.java | 6 ++---- .../test/java/org/aspectj/testing/util/MessageUtilTest.java | 5 ++--- .../src/test/java/org/aspectj/testing/util/TestDiffs.java | 9 +++------ .../java/org/aspectj/systemtest/model/ModelTestCase.java | 3 +-- util/src/main/java/org/aspectj/util/LangUtil.java | 3 +-- util/src/test/java/org/aspectj/util/FileUtilTest.java | 3 +-- .../main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java | 6 ++---- .../test/java/org/aspectj/weaver/ReferenceTypeTestCase.java | 3 +-- .../java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java | 6 ++---- .../aspectj/weaver/tools/Java15PointcutExpressionTest.java | 6 ++---- 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 l = new ArrayList<>(); - l.addAll(projectSourceFiles); + List 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 originalFileContents = new ArrayList<>(); - originalFileContents.addAll(fileContents); + List 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 getTargetersCopy() { - Set copy = new HashSet<>(); - copy.addAll(targeters); + Set 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 newYears = new ArrayList<>(); - newYears.addAll(years); + List 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 getSortedSamples(Comparator comparer) { - ArrayList result = new ArrayList<>(); - result.addAll(samples); + ArrayList 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 xmlfileList = new ArrayList<>(); - xmlfileList.addAll(parser.getXmlFiles()); + List xmlfileList = new ArrayList<>(parser.getXmlFiles()); List fileList = new ArrayList<>(); List 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 stb2 = new ArrayList<>(); - stb2.addAll(typesToProcess); + List 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 getFullClasspath() { - List full = new ArrayList<>(); - full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? + List 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 argList = new ArrayList<>(); - argList.addAll(getBaseArgs(targetSrc, targetClasses)); + ArrayList 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 tempSet = new HashSet<>(); - tempSet.addAll(other.shadowMungers); + Set tempSet = new HashSet<>(other.shadowMungers); Set otherShadowMungers = new HashSet<>(); Set 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 m = watp.annotationValues; Set keys = m.keySet(); - List orderedKeys = new ArrayList<>(); - orderedKeys.addAll(keys); + List orderedKeys = new ArrayList<>(keys); Collections.sort(orderedKeys); StringBuffer sb = new StringBuffer(); for (Iterator 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 finalList(String[] args) { - List result = new ArrayList<>(); - result.addAll(Arrays.asList(args)); + List 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 globals = new ArrayList<>(); final ArrayList files = new ArrayList<>(); - final LinkedList argList = new LinkedList<>(); - argList.addAll(Arrays.asList(args)); + final LinkedList argList = new LinkedList<>(Arrays.asList(args)); for (int i = 0; i < argList.size(); i++) { String arg = argList.get(i); List 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 expected = new ArrayList<>(); - expected.addAll(expectedOutputLines); - List found = new ArrayList<>(); - found.addAll(outputFound); + List expected = new ArrayList<>(expectedOutputLines); + List 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 expectedFileContents = new ArrayList<>(); - expectedFileContents.addAll(fileContents); + List 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 list = new ArrayList<>(); - list.addAll(Arrays.asList(array)); + ArrayList 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 sourceList = new ArrayList<>(); - sourceList.addAll(Arrays.asList(sources)); + List sourceList = new ArrayList<>(Arrays.asList(sources)); sourceList = Collections.unmodifiableList(sourceList); for (int k = 0; k < sources.length; k++) { List 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 unusedDecams = new HashSet<>(); - unusedDecams.addAll(decaMs); + Set 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 fields = clazz.getFieldGens(); if (fields != null) { - Set unusedDecafs = new HashSet<>(); - unusedDecafs.addAll(decafs); + Set 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 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 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 expected = new HashSet<>(); - expected.addAll(mpnv.getParameterTypeAnnotations()); + Set 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()) { -- cgit v1.2.3