8212718: Refactor some annotation processor tests to better use collections
Reviewed-by: jlaskey, vromero
--- a/test/langtools/tools/javac/processing/model/element/TestAnonClassNames.java Tue Oct 23 18:49:32 2018 +0200
+++ b/test/langtools/tools/javac/processing/model/element/TestAnonClassNames.java Tue Oct 23 10:32:39 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -129,22 +129,17 @@
static void testClassNames(List<String> classNames) {
System.out.println("test: " + classNames);
- List<String> options = new ArrayList<String>();
- options.add("-proc:only");
- options.add("-classpath");
- options.add(System.getProperty("test.classes"));
-
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
JavaCompiler.CompilationTask compileTask =
javaCompiler.getTask(null, // Output
null, // File manager
null, // Diagnostics
- options,
+ List.of("-proc:only", // options
+ "-classpath",
+ System.getProperty("test.classes")),
classNames,
null); // Sources
- List<Processor> processors = new ArrayList<Processor>();
- processors.add(new ClassNameProber());
- compileTask.setProcessors(processors);
+ compileTask.setProcessors(List.of(new ClassNameProber()));
Boolean goodResult = compileTask.call();
if (!goodResult) {
error("Errors found during compile.");
--- a/test/langtools/tools/javac/processing/model/element/TypeParamBounds.java Tue Oct 23 18:49:32 2018 +0200
+++ b/test/langtools/tools/javac/processing/model/element/TypeParamBounds.java Tue Oct 23 10:32:39 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -84,16 +84,12 @@
// The names of the bounds of each type parameter of Gen.
static Map<String, String[]> boundNames =
- new HashMap<String, String[]>();
-
- static {
- boundNames.put("T", new String[] {"Object"});
- boundNames.put("U", new String[] {"Object"});
- boundNames.put("V", new String[] {"Number"});
- boundNames.put("W", new String[] {"U"});
- boundNames.put("X", new String[] {"Runnable"});
- boundNames.put("Y", new String[] {"CharSequence", "Runnable"});
- boundNames.put("Z", new String[] {"Object", "Runnable"});
- }
+ Map.of("T", new String[] {"Object"},
+ "U", new String[] {"Object"},
+ "V", new String[] {"Number"},
+ "W", new String[] {"U"},
+ "X", new String[] {"Runnable"},
+ "Y", new String[] {"CharSequence", "Runnable"},
+ "Z", new String[] {"Object", "Runnable"});
}
}