8212718: Refactor some annotation processor tests to better use collections

Reviewed-by: jlaskey, vromero
This commit is contained in:
Joe Darcy 2018-10-23 10:32:39 -07:00
parent 272eb6824b
commit 34397c4914
2 changed files with 13 additions and 22 deletions

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -129,22 +129,17 @@ public class TestAnonClassNames {
static void testClassNames(List<String> classNames) { static void testClassNames(List<String> classNames) {
System.out.println("test: " + 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 javaCompiler = ToolProvider.getSystemJavaCompiler();
JavaCompiler.CompilationTask compileTask = JavaCompiler.CompilationTask compileTask =
javaCompiler.getTask(null, // Output javaCompiler.getTask(null, // Output
null, // File manager null, // File manager
null, // Diagnostics null, // Diagnostics
options, List.of("-proc:only", // options
"-classpath",
System.getProperty("test.classes")),
classNames, classNames,
null); // Sources null); // Sources
List<Processor> processors = new ArrayList<Processor>(); compileTask.setProcessors(List.of(new ClassNameProber()));
processors.add(new ClassNameProber());
compileTask.setProcessors(processors);
Boolean goodResult = compileTask.call(); Boolean goodResult = compileTask.call();
if (!goodResult) { if (!goodResult) {
error("Errors found during compile."); error("Errors found during compile.");

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -84,16 +84,12 @@ public class TypeParamBounds extends JavacTestingAbstractProcessor {
// The names of the bounds of each type parameter of Gen. // The names of the bounds of each type parameter of Gen.
static Map<String, String[]> boundNames = static Map<String, String[]> boundNames =
new HashMap<String, String[]>(); Map.of("T", new String[] {"Object"},
"U", new String[] {"Object"},
static { "V", new String[] {"Number"},
boundNames.put("T", new String[] {"Object"}); "W", new String[] {"U"},
boundNames.put("U", new String[] {"Object"}); "X", new String[] {"Runnable"},
boundNames.put("V", new String[] {"Number"}); "Y", new String[] {"CharSequence", "Runnable"},
boundNames.put("W", new String[] {"U"}); "Z", new String[] {"Object", "Runnable"});
boundNames.put("X", new String[] {"Runnable"});
boundNames.put("Y", new String[] {"CharSequence", "Runnable"});
boundNames.put("Z", new String[] {"Object", "Runnable"});
}
} }
} }