aboutsummaryrefslogtreecommitdiffstats
path: root/bcel-builder
diff options
context:
space:
mode:
Diffstat (limited to 'bcel-builder')
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java13
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java8
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java4
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java3
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java9
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java13
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java10
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java6
-rw-r--r--bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java4
-rw-r--r--bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java3
10 files changed, 26 insertions, 47 deletions
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java
index dd1097ff0..014ad558d 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java
@@ -60,12 +60,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.StringTokenizer;
+import java.util.*;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
@@ -746,7 +741,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node {
for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) {
vec.add(clazz);
}
- return vec.toArray(new JavaClass[vec.size()]);
+ return vec.toArray(new JavaClass[0]);
}
/**
@@ -791,9 +786,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node {
}
}
- for (JavaClass anInterface : interfaces) {
- queue.add(anInterface);
- }
+ Collections.addAll(queue, interfaces);
}
return interfaceList;
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java
index 943b77f6e..03c7c716b 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java
@@ -196,7 +196,7 @@ public class ClassGen extends Modifiers implements Cloneable {
ConstantPool cp = this.cpool.getFinalConstantPool();
return new JavaClass(classnameIndex, superclassnameIndex, filename, major, minor, modifiers, cp, interfaces, fields,
- methods, attributes.toArray(new Attribute[attributes.size()]));// OPTIMIZE avoid toArray()?
+ methods, attributes.toArray(new Attribute[0]));// OPTIMIZE avoid toArray()?
}
public void addInterface(String name) {
@@ -509,7 +509,7 @@ public class ClassGen extends Modifiers implements Cloneable {
relevantFields.add(field);
}
}
- Collections.sort(relevantFields, new FieldComparator());
+ relevantFields.sort(new FieldComparator());
int relevantFlags = Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED | Constants.ACC_STATIC
| Constants.ACC_FINAL | Constants.ACC_VOLATILE | Constants.ACC_TRANSIENT;
for (Field f : relevantFields) {
@@ -534,8 +534,8 @@ public class ClassGen extends Modifiers implements Cloneable {
relevantMethods.add(m);
}
}
- Collections.sort(relevantCtors, new ConstructorComparator());
- Collections.sort(relevantMethods, new MethodComparator());
+ relevantCtors.sort(new ConstructorComparator());
+ relevantMethods.sort(new MethodComparator());
// 5. If a class initializer exists, write out the following:
// 1. The name of the method, <clinit>.
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java
index c8e1fe2fb..5b4256685 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java
@@ -76,8 +76,8 @@ public abstract class FieldGenOrMethodGen extends Modifiers {
protected String name;
protected Type type;
protected ConstantPool cp;
- private ArrayList<Attribute> attributeList = new ArrayList<>();
- protected ArrayList<AnnotationGen> annotationList = new ArrayList<>();
+ private List<Attribute> attributeList = new ArrayList<>();
+ protected List<AnnotationGen> annotationList = new ArrayList<>();
protected FieldGenOrMethodGen() {
}
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/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java
index 156adf0ad..7938218bc 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java
@@ -58,10 +58,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
+import java.util.*;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Constant;
@@ -690,7 +687,7 @@ public class InstructionList implements Serializable {
return;
}
- ArrayList<InstructionHandle> target_vec = new ArrayList<>();
+ List<InstructionHandle> target_vec = new ArrayList<>();
for (InstructionHandle ih = first; ih != null; ih = ih.next) {
ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets
@@ -1003,7 +1000,7 @@ public class InstructionList implements Serializable {
*/
public Instruction[] getInstructions() {
ByteSequence bytes = new ByteSequence(getByteCode());
- ArrayList<Instruction> instructions = new ArrayList<>();
+ List<Instruction> instructions = new ArrayList<>();
try {
while (bytes.available() > 0) {
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java
index 9541052a1..453fe7c1f 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java
@@ -54,10 +54,7 @@ package org.aspectj.apache.bcel.generic;
* <http://www.apache.org/>.
*/
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Stack;
+import java.util.*;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Attribute;
@@ -102,11 +99,11 @@ public class MethodGen extends FieldGenOrMethodGen {
private int highestLineNumber = 0;
- private ArrayList<LocalVariableGen> localVariablesList = new ArrayList<>();
- private ArrayList<LineNumberGen> lineNumbersList = new ArrayList<>();
+ private List<LocalVariableGen> localVariablesList = new ArrayList<>();
+ private List<LineNumberGen> lineNumbersList = new ArrayList<>();
private ArrayList<CodeExceptionGen> exceptionsList = new ArrayList<>();
private ArrayList<String> exceptionsThrown = new ArrayList<>();
- private ArrayList<Attribute> codeAttributesList = new ArrayList<>();
+ private List<Attribute> codeAttributesList = new ArrayList<>();
private List<AnnotationGen>[] param_annotations; // Array of lists containing AnnotationGen objects
private boolean hasParameterAnnotations = false;
private boolean haveUnpackedParameterAnnotations = false;
@@ -933,7 +930,7 @@ public class MethodGen extends FieldGenOrMethodGen {
static final class BranchStack {
Stack<BranchTarget> branchTargets = new Stack<>();
- Hashtable<InstructionHandle, BranchTarget> visitedTargets = new Hashtable<>();
+ Map<InstructionHandle, BranchTarget> visitedTargets = new Hashtable<>();
public void push(InstructionHandle target, int stackDepth) {
if (visited(target)) {
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java
index 179800540..678abb1dc 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java
@@ -69,11 +69,7 @@ import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
+import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -106,7 +102,7 @@ public class ClassPath implements Serializable {
public ClassPath(String class_path) {
this.class_path = class_path;
- ArrayList<PathEntry> vec = new ArrayList<>();
+ List<PathEntry> vec = new ArrayList<>();
for (StringTokenizer tok = new StringTokenizer(class_path, System.getProperty("path.separator")); tok
.hasMoreTokens();) {
@@ -167,7 +163,7 @@ public class ClassPath implements Serializable {
return false;
}
- private static final void getPathComponents(String path, ArrayList<String> list) {
+ private static final void getPathComponents(String path, List<String> list) {
if (path != null) {
StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java
index 595a50b0a..e2e5f38bb 100644
--- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java
+++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java
@@ -210,11 +210,7 @@ public class NonCachingClassLoaderRepository implements Repository {
*/
public JavaClass findClass(String className) {
synchronized (loadedClasses) {
- if (loadedClasses.containsKey(className)) {
- return loadedClasses.get(className);
- } else {
- return null;
- }
+ return loadedClasses.getOrDefault(className, null);
}
}
diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
index d684144eb..84f9d9532 100644
--- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
+++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
@@ -97,7 +97,7 @@ public class AnnotationGenTest extends BcelTestCase {
// Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :)
AnnotationGen a = new AnnotationGen(t, elements, true, cp);
- Vector<AnnotationGen> v = new Vector<>();
+ List<AnnotationGen> v = new Vector<>();
v.add(a);
Collection<RuntimeAnnos> attributes = Utility.getAnnotationAttributes(cp, v);
boolean foundRV = false;
@@ -113,7 +113,7 @@ public class AnnotationGenTest extends BcelTestCase {
// Build a RIV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :)
AnnotationGen a2 = new AnnotationGen(t, elements, false, cp);
- Vector<AnnotationGen> v2 = new Vector<>();
+ List<AnnotationGen> v2 = new Vector<>();
v2.add(a2);
Collection<RuntimeAnnos> attributes2 = Utility.getAnnotationAttributes(cp, v2);
boolean foundRIV = false;
diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java
index 255dc77ff..c97e12678 100644
--- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java
+++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java
@@ -12,6 +12,7 @@
package org.aspectj.apache.bcel.classfile.tests;
import java.util.ArrayList;
+import java.util.List;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Attribute;
@@ -415,7 +416,7 @@ public class GenericSignatureParsingTest extends BcelTestCase {
* @return Array of argument types
*/
public static final String[] methodSignatureArgumentTypes(String signature,boolean chopit) throws ClassFormatException {
- ArrayList<String> vec = new ArrayList<>();
+ List<String> vec = new ArrayList<>();
int index;
String[] types;