From 639f5030e0391e831138f9786cf831c3374449e7 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 15 Aug 2020 17:01:46 +0200 Subject: Weaken Collection declarations Reports on declarations of Collection variables made by using the collection class as the type, rather than an appropriate interface. Signed-off-by: Lars Grefer --- util/src/main/java/org/aspectj/util/FileUtil.java | 2 +- util/src/main/java/org/aspectj/util/LangUtil.java | 6 +++--- util/src/main/java/org/aspectj/util/UtilClassLoader.java | 2 +- util/src/test/java/org/aspectj/util/FileUtilTest.java | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'util/src') diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java index a586b69f6..363056491 100644 --- a/util/src/main/java/org/aspectj/util/FileUtil.java +++ b/util/src/main/java/org/aspectj/util/FileUtil.java @@ -1294,7 +1294,7 @@ public class FileUtil { * @param List sink the List for String entries of the form {sourcePath}:line:column * @return String error if any, or add String entries to sink */ - public static String lineSeek(String sought, String sourcePath, boolean listAll, ArrayList sink) { + public static String lineSeek(String sought, String sourcePath, boolean listAll, List sink) { if (LangUtil.isEmpty(sought) || LangUtil.isEmpty(sourcePath)) { return "nothing sought"; } diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index e97438b0e..edfc48f70 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -359,7 +359,7 @@ public class LangUtil { if (null == input) { return Collections.emptyList(); } - ArrayList result = new ArrayList<>(); + List result = new ArrayList<>(); if (LangUtil.isEmpty(delim) || (!input.contains(delim))) { result.add(input.trim()); @@ -741,7 +741,7 @@ public class LangUtil { final int sinkLength = (null == sink ? 0 : sink.length); final int resultSize; - ArrayList result = null; + List result = null; if (0 == sourceLength) { resultSize = 0; } else { @@ -1000,7 +1000,7 @@ public class LangUtil { if ((null == array) || (1 > array.length)) { return Collections.emptyList(); } - ArrayList list = new ArrayList<>(Arrays.asList(array)); + List list = new ArrayList<>(Arrays.asList(array)); return list; } diff --git a/util/src/main/java/org/aspectj/util/UtilClassLoader.java b/util/src/main/java/org/aspectj/util/UtilClassLoader.java index b4d09533f..2cb522f90 100644 --- a/util/src/main/java/org/aspectj/util/UtilClassLoader.java +++ b/util/src/main/java/org/aspectj/util/UtilClassLoader.java @@ -40,7 +40,7 @@ public class UtilClassLoader extends URLClassLoader { super(urls); LangUtil.throwIaxIfNotAssignable(dirs, File.class, "dirs"); this.urlsForDebugString = urls; - ArrayList dcopy = new ArrayList<>(); + List dcopy = new ArrayList<>(); if (!LangUtil.isEmpty(dirs)) { dcopy.addAll(Arrays.asList(dirs)); diff --git a/util/src/test/java/org/aspectj/util/FileUtilTest.java b/util/src/test/java/org/aspectj/util/FileUtilTest.java index f5466e2cf..29cd246e4 100644 --- a/util/src/test/java/org/aspectj/util/FileUtilTest.java +++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java @@ -62,7 +62,7 @@ public class FileUtilTest extends TestCase { * @throws AssertionFailedError if any names are not in dir */ public static String[] dirContains(File dir, final String[] filenames) { - final ArrayList sought = new ArrayList<>(LangUtil.arrayAsList(filenames)); + final List sought = new ArrayList<>(LangUtil.arrayAsList(filenames)); FilenameFilter filter = new FilenameFilter() { public boolean accept(File d, String name) { return !sought.remove(name); @@ -188,7 +188,7 @@ public class FileUtilTest extends TestCase { } /** List of File files or directories to delete when exiting */ - final ArrayList tempFiles; + final List tempFiles; public FileUtilTest(String s) { super(s); @@ -388,7 +388,7 @@ public class FileUtilTest extends TestCase { } public void testRandomFileString() { - ArrayList results = new ArrayList<>(); + List results = new ArrayList<>(); for (int i = 0; i < 1000; i++) { String s = FileUtil.randomFileString(); if (results.contains(s)) { @@ -462,7 +462,7 @@ public class FileUtilTest extends TestCase { List sourceList = new ArrayList<>(); sourceList.add(file.getPath()); - final ArrayList errors = new ArrayList<>(); + final List errors = new ArrayList<>(); final PrintStream errorSink = new PrintStream(System.err, true) { public void println(String error) { errors.add(error); @@ -502,7 +502,7 @@ public class FileUtilTest extends TestCase { tempFiles.add(file); } // now test - final ArrayList errors = new ArrayList<>(); + final List errors = new ArrayList<>(); final PrintStream errorSink = new PrintStream(System.err, true) { public void println(String error) { errors.add(error); -- cgit v1.2.3