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 --- .../java/org/aspectj/weaver/bcel/BcelWeaver.java | 2 +- .../org/aspectj/weaver/bcel/ClassPathManager.java | 4 +-- .../org/aspectj/weaver/bcel/LazyMethodGen.java | 4 +-- .../loadtime/definition/SimpleAOPParser.java | 2 +- .../org/aspectj/weaver/ReferenceTypeTestCase.java | 36 +++++++++++----------- 5 files changed, 24 insertions(+), 24 deletions(-) (limited to 'weaver') diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java index b80080ec1..110d58c88 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java @@ -946,7 +946,7 @@ public class BcelWeaver { manifest = new Manifest(); - Attributes attributes = manifest.getMainAttributes(); + Map attributes = manifest.getMainAttributes(); attributes.put(Name.MANIFEST_VERSION, WEAVER_MANIFEST_VERSION); attributes.put(CREATED_BY, WEAVER_CREATED_BY); } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java index cd378dbbf..76acc6e7f 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java @@ -352,12 +352,12 @@ public class ClassPathManager { FileSystem fs = null; try { if (LangUtil.is19VMOrGreater()) { - HashMap env = new HashMap<>(); + Map env = new HashMap<>(); env.put("java.home", jdkHome); fs = FileSystems.newFileSystem(JRT_URI, env); } else { URLClassLoader loader = new URLClassLoader(new URL[] { jrtPath }); - HashMap env = new HashMap<>(); + Map env = new HashMap<>(); fs = FileSystems.newFileSystem(JRT_URI, env, loader); } state = new JImageState(jrtFsPath, fs); 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 7e2541e6c..7bac02dad 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -1359,7 +1359,7 @@ public final class LazyMethodGen implements Traceable { } private void addExceptionHandlers(MethodGen gen, Map map, - LinkedList exnList) { + Iterable exnList) { // now add exception handlers for (ExceptionRange r : exnList) { if (r.isEmpty()) { @@ -1547,7 +1547,7 @@ public final class LazyMethodGen implements Traceable { // but I don't trust the only implementation, TreeSet, to do the right // thing. - /* private */static void insertHandler(ExceptionRange fresh, LinkedList l) { + /* private */static void insertHandler(ExceptionRange fresh, List l) { // Old implementation, simply: l.add(0,fresh); for (ListIterator iter = l.listIterator(); iter.hasNext();) { ExceptionRange r = iter.next(); diff --git a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java index e49988a89..8d912a317 100644 --- a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java +++ b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java @@ -253,7 +253,7 @@ public class SimpleAOPParser { private static void traverse(SimpleAOPParser sap, LightXMLParser xml) throws Exception { sap.startElement(xml.getName(), xml.getAttributes()); - ArrayList childrens = xml.getChildrens(); + Iterable childrens = xml.getChildrens(); for (Object children : childrens) { LightXMLParser child = (LightXMLParser) children; traverse(sap, child); diff --git a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java index f9b020272..fbe505292 100644 --- a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java @@ -191,13 +191,13 @@ public class ReferenceTypeTestCase extends TestCase { public void testAssignable02() { List list = new ArrayList(); - ArrayList arraylist = null; + List arraylist = null; List listOfString = new ArrayList<>(); List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; + List arrayListOfSomething = null; List listOfNumber = null; ArrayList arrayListOfNumber = null; - ArrayList arrayListOfSomethingNumberish = null; + List arrayListOfSomethingNumberish = null; List listOfSomethingNumberish = new ArrayList(); List listOfSomethingSuperDouble = new ArrayList(); List listOfInteger = new ArrayList<>(); @@ -274,14 +274,14 @@ public class ReferenceTypeTestCase extends TestCase { public void testAssignable03_method_m2() { List list = new ArrayList(); - ArrayList arraylist = null; + List arraylist = null; List listOfString = new ArrayList<>(); List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; + List arrayListOfSomething = null; List listOfNumber = null; - ArrayList arrayListOfNumber = null; - ArrayList arrayListOfInteger = null; - ArrayList arrayListOfSomethingNumberish = null; + List arrayListOfNumber = null; + List arrayListOfInteger = null; + List arrayListOfSomethingNumberish = null; List listOfSomethingNumberish = new ArrayList(); List listOfSomethingSuperDouble = new ArrayList(); List listOfInteger = new ArrayList<>(); @@ -364,15 +364,15 @@ public class ReferenceTypeTestCase extends TestCase { ArrayList arraylist = null; List listOfString = new ArrayList<>(); List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; + List arrayListOfSomething = null; List listOfNumber = null; - ArrayList arrayListOfNumber = null; + List arrayListOfNumber = null; ArrayList arrayListOfInteger = null; - ArrayList arrayListOfSomethingNumberish = null; + List arrayListOfSomethingNumberish = null; List listOfSomethingNumberish = new ArrayList(); List listOfSomethingSuperDouble = new ArrayList(); List listOfInteger = new ArrayList<>(); - ArrayList arrayList = null; + List arrayList = null; ArrayList arrayListOfString; ArrayList arraylistOfInteger; // interfaces too List @@ -477,18 +477,18 @@ public class ReferenceTypeTestCase extends TestCase { public void testAssignable03_method_m4() { List list = new ArrayList(); - ArrayList arraylist = null; + List arraylist = null; List listOfString = new ArrayList<>(); List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; + List arrayListOfSomething = null; List listOfNumber = null; - ArrayList arrayListOfNumber = null; - ArrayList arrayListOfSomethingNumberish = null; + List arrayListOfNumber = null; + List arrayListOfSomethingNumberish = null; List listOfSomethingNumberish = new ArrayList(); List listOfSomethingSuperDouble = new ArrayList(); List listOfInteger = new ArrayList<>(); - ArrayList arrayListOfString; - ArrayList arraylistOfInteger; + List arrayListOfString; + List arraylistOfInteger; // interfaces too List ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); -- cgit v1.2.3