aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-13 01:01:58 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-13 01:01:58 +0200
commite1bff9a5703baf17ec650b173bdfe776bf87125f (patch)
tree8b4443759c231a6c46cb70c755fe554a4b621e11 /util
parentb6eee2e1052116aa22ebbd3c2baf05c2b709bee5 (diff)
downloadaspectj-e1bff9a5703baf17ec650b173bdfe776bf87125f.tar.gz
aspectj-e1bff9a5703baf17ec650b173bdfe776bf87125f.zip
Use the diamond operator where possible
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'util')
-rw-r--r--util/src/main/java/org/aspectj/util/FileUtil.java12
-rw-r--r--util/src/main/java/org/aspectj/util/GenericSignatureParser.java18
-rw-r--r--util/src/main/java/org/aspectj/util/LangUtil.java18
-rw-r--r--util/src/main/java/org/aspectj/util/PartialOrder.java10
-rw-r--r--util/src/main/java/org/aspectj/util/Reflection.java6
-rw-r--r--util/src/main/java/org/aspectj/util/SoftHashMap.java4
-rw-r--r--util/src/main/java/org/aspectj/util/UtilClassLoader.java2
-rw-r--r--util/src/test/java/org/aspectj/util/FileUtilTest.java8
8 files changed, 39 insertions, 39 deletions
diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java
index 1927f47a0..976c3ccbc 100644
--- a/util/src/main/java/org/aspectj/util/FileUtil.java
+++ b/util/src/main/java/org/aspectj/util/FileUtil.java
@@ -686,7 +686,7 @@ public class FileUtil {
* @return ArrayList with String paths of File under srcDir (relative to srcDir)
*/
public static String[] listFiles(File srcDir) {
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
if ((null != srcDir) && srcDir.canRead()) {
listFiles(srcDir, null, result);
}
@@ -706,7 +706,7 @@ public class FileUtil {
* @return ArrayList with String paths of File under srcDir (relative to srcDir)
*/
public static File[] listFiles(File srcDir, FileFilter fileFilter) {
- ArrayList<File> result = new ArrayList<File>();
+ ArrayList<File> result = new ArrayList<>();
if ((null != srcDir) && srcDir.canRead()) {
listFiles(srcDir, result, fileFilter);
}
@@ -719,7 +719,7 @@ public class FileUtil {
* @return List of File objects
*/
public static List<File> listClassFiles(File dir) {
- ArrayList<File> result = new ArrayList<File>();
+ ArrayList<File> result = new ArrayList<>();
if ((null != dir) && dir.canRead()) {
listClassFiles(dir, result);
}
@@ -750,7 +750,7 @@ public class FileUtil {
LangUtil.throwIaxIfNull(paths, "paths");
File[] result = null;
if (!LangUtil.isEmpty(suffixes)) {
- ArrayList<File> list = new ArrayList<File>();
+ ArrayList<File> list = new ArrayList<>();
for (String path : paths) {
for (String suffix : suffixes) {
if (path.endsWith(suffix)) {
@@ -1273,7 +1273,7 @@ public class FileUtil {
if (LangUtil.isEmpty(sought) || LangUtil.isEmpty(sources)) {
return Collections.emptyList();
}
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
for (String path : sources) {
String error = lineSeek(sought, path, listAll, result);
if ((null != error) && (null != errorSink)) {
@@ -1427,7 +1427,7 @@ public class FileUtil {
}
public static List<String> makeClasspath(URL[] urls) {
- List<String> ret = new LinkedList<String>();
+ List<String> ret = new LinkedList<>();
if (urls != null) {
for (URL url : urls) {
ret.add(toPathString(url));
diff --git a/util/src/main/java/org/aspectj/util/GenericSignatureParser.java b/util/src/main/java/org/aspectj/util/GenericSignatureParser.java
index 27670cc00..3e1e0e7b3 100644
--- a/util/src/main/java/org/aspectj/util/GenericSignatureParser.java
+++ b/util/src/main/java/org/aspectj/util/GenericSignatureParser.java
@@ -46,7 +46,7 @@ public class GenericSignatureParser {
GenericSignature.ClassSignature classSig = new GenericSignature.ClassSignature();
// FormalTypeParameters-opt
if (maybeEat("<")) {
- List<FormalTypeParameter> formalTypeParametersList = new ArrayList<FormalTypeParameter>();
+ List<FormalTypeParameter> formalTypeParametersList = new ArrayList<>();
do {
formalTypeParametersList.add(parseFormalTypeParameter());
} while (!maybeEat(">"));
@@ -54,7 +54,7 @@ public class GenericSignatureParser {
formalTypeParametersList.toArray(classSig.formalTypeParameters);
}
classSig.superclassSignature = parseClassTypeSignature();
- List<ClassTypeSignature> superIntSigs = new ArrayList<ClassTypeSignature>();
+ List<ClassTypeSignature> superIntSigs = new ArrayList<>();
while (tokenIndex < tokenStream.length) {
superIntSigs.add(parseClassTypeSignature());
}
@@ -75,7 +75,7 @@ public class GenericSignatureParser {
TypeSignature returnType = null;
// FormalTypeParameters-opt
if (maybeEat("<")) {
- List<FormalTypeParameter> formalTypeParametersList = new ArrayList<FormalTypeParameter>();
+ List<FormalTypeParameter> formalTypeParametersList = new ArrayList<>();
do {
formalTypeParametersList.add(parseFormalTypeParameter());
} while (!maybeEat(">"));
@@ -84,7 +84,7 @@ public class GenericSignatureParser {
}
// Parameters
eat("(");
- List<TypeSignature> paramList = new ArrayList<TypeSignature>();
+ List<TypeSignature> paramList = new ArrayList<>();
while (!maybeEat(")")) {
FieldTypeSignature fsig = parseFieldTypeSignature(true);
if (fsig != null) {
@@ -100,7 +100,7 @@ public class GenericSignatureParser {
if (returnType == null)
returnType = new GenericSignature.BaseTypeSignature(eatIdentifier());
// throws
- List<FieldTypeSignature> throwsList = new ArrayList<FieldTypeSignature>();
+ List<FieldTypeSignature> throwsList = new ArrayList<>();
while (maybeEat("^")) {
FieldTypeSignature fsig = parseFieldTypeSignature(false);
throwsList.add(fsig);
@@ -132,7 +132,7 @@ public class GenericSignatureParser {
ftp.classBound = new ClassTypeSignature("Ljava/lang/Object;", "Ljava/lang/Object");
}
// Optional InterfaceBounds
- List<FieldTypeSignature> optionalBounds = new ArrayList<FieldTypeSignature>();
+ List<FieldTypeSignature> optionalBounds = new ArrayList<>();
while (maybeEat(":")) {
optionalBounds.add(parseFieldTypeSignature(false));
}
@@ -218,7 +218,7 @@ public class GenericSignatureParser {
private SimpleClassTypeSignature[] parseNestedTypesHelper(StringBuffer ret) {
boolean brokenSignature = false;
SimpleClassTypeSignature[] nestedTypes;
- List<SimpleClassTypeSignature> nestedTypeList = new ArrayList<SimpleClassTypeSignature>();
+ List<SimpleClassTypeSignature> nestedTypeList = new ArrayList<>();
while (maybeEat(".")) {
ret.append(".");
SimpleClassTypeSignature sig = parseSimpleClassTypeSignature();
@@ -270,7 +270,7 @@ public class GenericSignatureParser {
private TypeArgument[] maybeParseTypeArguments() {
if (maybeEat("<")) {
- List<TypeArgument> typeArgs = new ArrayList<TypeArgument>();
+ List<TypeArgument> typeArgs = new ArrayList<>();
do {
TypeArgument arg = parseTypeArgument();
typeArgs.add(arg);
@@ -317,7 +317,7 @@ public class GenericSignatureParser {
public String[] tokenize(String signatureString) {
char[] chars = signatureString.toCharArray();
int index = 0;
- List<String> tokens = new ArrayList<String>();
+ List<String> tokens = new ArrayList<>();
StringBuffer identifier = new StringBuffer();
boolean inParens = false;
boolean inArray = false;
diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java
index ffdc0b66e..5c656cd7a 100644
--- a/util/src/main/java/org/aspectj/util/LangUtil.java
+++ b/util/src/main/java/org/aspectj/util/LangUtil.java
@@ -113,7 +113,7 @@ public class LangUtil {
}
private static List<Integer> getFirstNumbers(String vm) {
- List<Integer> result = new ArrayList<Integer>();
+ List<Integer> result = new ArrayList<>();
StringTokenizer st = new StringTokenizer(vm,".-_");
try {
result.add(Integer.parseInt(st.nextToken()));
@@ -312,7 +312,7 @@ public class LangUtil {
return new String[0];
}
StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator);
- ArrayList<String> result = new ArrayList<String>(st.countTokens());
+ ArrayList<String> result = new ArrayList<>(st.countTokens());
while (st.hasMoreTokens()) {
String entry = st.nextToken();
if (!LangUtil.isEmpty(entry)) {
@@ -354,7 +354,7 @@ public class LangUtil {
if (null == input) {
return Collections.emptyList();
}
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
if (LangUtil.isEmpty(delim) || (!input.contains(delim))) {
result.add(input.trim());
@@ -376,7 +376,7 @@ public class LangUtil {
if (LangUtil.isEmpty(text)) {
return Collections.emptyList();
}
- List<String> strings = new ArrayList<String>();
+ List<String> strings = new ArrayList<>();
StringTokenizer tok = new StringTokenizer(text);
while (tok.hasMoreTokens()) {
strings.add(tok.nextToken());
@@ -740,7 +740,7 @@ public class LangUtil {
if (0 == sourceLength) {
resultSize = 0;
} else {
- result = new ArrayList<Object>(sourceLength);
+ result = new ArrayList<>(sourceLength);
for (int i = 0; i < sourceLength; i++) {
if ((null != source[i]) && (sinkType.isAssignableFrom(source[i].getClass()))) {
result.add(source[i]);
@@ -897,7 +897,7 @@ public class LangUtil {
if (null == checker || (null == stack) || (0 == stack.length())) {
return;
}
- final LinkedList<String> lines = new LinkedList<String>();
+ final LinkedList<String> lines = new LinkedList<>();
StringTokenizer st = new StringTokenizer(stack.toString(), "\n\r");
while (st.hasMoreTokens() && (0 < --maxLines)) {
lines.add(st.nextToken());
@@ -995,7 +995,7 @@ public class LangUtil {
if ((null == array) || (1 > array.length)) {
return Collections.emptyList();
}
- ArrayList<T> list = new ArrayList<T>();
+ ArrayList<T> list = new ArrayList<>();
list.addAll(Arrays.asList(array));
return list;
}
@@ -1073,7 +1073,7 @@ public class LangUtil {
*/
public static ProcessController makeProcess(ProcessController controller, String classpath, String mainClass, String[] args) {
File java = LangUtil.getJavaExecutable();
- ArrayList<String> cmd = new ArrayList<String>();
+ ArrayList<String> cmd = new ArrayList<>();
cmd.add(java.getAbsolutePath());
cmd.add("-classpath");
cmd.add(classpath);
@@ -1262,7 +1262,7 @@ public class LangUtil {
LangUtil.throwIaxIfNull(java, "java");
LangUtil.throwIaxIfNull(mainClass, "mainClass");
LangUtil.throwIaxIfNull(args, "args");
- ArrayList<String> cmd = new ArrayList<String>();
+ ArrayList<String> cmd = new ArrayList<>();
cmd.add(java.getAbsolutePath());
cmd.add("-classpath");
cmd.add(classpath);
diff --git a/util/src/main/java/org/aspectj/util/PartialOrder.java b/util/src/main/java/org/aspectj/util/PartialOrder.java
index 14f23b0d6..be59104a0 100644
--- a/util/src/main/java/org/aspectj/util/PartialOrder.java
+++ b/util/src/main/java/org/aspectj/util/PartialOrder.java
@@ -51,8 +51,8 @@ public class PartialOrder {
private static class SortObject<T extends PartialComparable> {
T object;
- List<SortObject<T>> smallerObjects = new LinkedList<SortObject<T>>();
- List<SortObject<T>> biggerObjects = new LinkedList<SortObject<T>>();
+ List<SortObject<T>> smallerObjects = new LinkedList<>();
+ List<SortObject<T>> biggerObjects = new LinkedList<>();
public SortObject(T o) {
object = o;
@@ -87,7 +87,7 @@ public class PartialOrder {
}
private static <T extends PartialComparable> void addNewPartialComparable(List<SortObject<T>> graph, T o) {
- SortObject<T> so = new SortObject<T>(o);
+ SortObject<T> so = new SortObject<>(o);
for (SortObject<T> other : graph) {
so.addDirectedLinks(other);
}
@@ -123,7 +123,7 @@ public class PartialOrder {
// ??? I don't like creating this data structure, but it does give good
// ??? separation of concerns.
- List<SortObject<T>> sortList = new LinkedList<SortObject<T>>();
+ List<SortObject<T>> sortList = new LinkedList<>();
for (T object : objects) {
addNewPartialComparable(sortList, object);
}
@@ -193,7 +193,7 @@ public class PartialOrder {
}
public static void main(String[] args) {
- List<Token> l = new ArrayList<Token>();
+ List<Token> l = new ArrayList<>();
l.add(new Token("a1"));
l.add(new Token("c2"));
l.add(new Token("b3"));
diff --git a/util/src/main/java/org/aspectj/util/Reflection.java b/util/src/main/java/org/aspectj/util/Reflection.java
index d78f67101..614bb4b76 100644
--- a/util/src/main/java/org/aspectj/util/Reflection.java
+++ b/util/src/main/java/org/aspectj/util/Reflection.java
@@ -96,9 +96,9 @@ public class Reflection {
runMainInSameVM(mainClass, args);
return;
}
- ArrayList<File> dirs = new ArrayList<File>();
- ArrayList<File> libs = new ArrayList<File>();
- ArrayList<URL> urls = new ArrayList<URL>();
+ ArrayList<File> dirs = new ArrayList<>();
+ ArrayList<File> libs = new ArrayList<>();
+ ArrayList<URL> urls = new ArrayList<>();
String[] entries = LangUtil.splitClasspath(classpath);
for (String entry : entries) {
URL url = makeURL(entry);
diff --git a/util/src/main/java/org/aspectj/util/SoftHashMap.java b/util/src/main/java/org/aspectj/util/SoftHashMap.java
index 7660525d1..8af2e6304 100644
--- a/util/src/main/java/org/aspectj/util/SoftHashMap.java
+++ b/util/src/main/java/org/aspectj/util/SoftHashMap.java
@@ -19,7 +19,7 @@ public class SoftHashMap<K,V> extends AbstractMap<K,V> {
private ReferenceQueue<? super V> rq = new ReferenceQueue();
public SoftHashMap() {
- this.map = new HashMap<K,SpecialValue>();
+ this.map = new HashMap<>();
}
class SpecialValue extends SoftReference<V> {
@@ -65,7 +65,7 @@ public class SoftHashMap<K,V> extends AbstractMap<K,V> {
@Override
public java.util.Set<Map.Entry<K,V>> entrySet() {
if (map.isEmpty()) { return Collections.<K,V>emptyMap().entrySet(); }
- Map<K,V> currentContents = new HashMap<K,V>();
+ Map<K,V> currentContents = new HashMap<>();
for (Map.Entry<K,SpecialValue> entry: map.entrySet()) {
V currentValueForEntry = entry.getValue().get();
if (currentValueForEntry != null) {
diff --git a/util/src/main/java/org/aspectj/util/UtilClassLoader.java b/util/src/main/java/org/aspectj/util/UtilClassLoader.java
index 4704bfcc9..b4d09533f 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<File> dcopy = new ArrayList<File>();
+ ArrayList<File> 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 663352be6..7936914fb 100644
--- a/util/src/test/java/org/aspectj/util/FileUtilTest.java
+++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java
@@ -129,7 +129,7 @@ public class FileUtilTest extends TestCase {
* @return sorted String[] of all paths to all files under dir ending with one of the listed suffixes but not starting with "."
*/
public static String[] dirPaths(File dir, String[] suffixes) {
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
doDirPaths(dir, result);
// if suffixes required, remove those without suffixes
if (!LangUtil.isEmpty(suffixes)) {
@@ -192,7 +192,7 @@ public class FileUtilTest extends TestCase {
public FileUtilTest(String s) {
super(s);
- tempFiles = new ArrayList<File>();
+ tempFiles = new ArrayList<>();
}
public void tearDown() {
@@ -459,10 +459,10 @@ public class FileUtilTest extends TestCase {
contents += contents;
FileUtil.writeAsString(file, contents);
tempFiles.add(file);
- List<String> sourceList = new ArrayList<String>();
+ List<String> sourceList = new ArrayList<>();
sourceList.add(file.getPath());
- final ArrayList<String> errors = new ArrayList<String>();
+ final ArrayList<String> errors = new ArrayList<>();
final PrintStream errorSink = new PrintStream(System.err, true) {
public void println(String error) {
errors.add(error);