8014363: javac test class ToolTester handles classpath incorrectly
Reviewed-by: ksrini
--- a/langtools/test/tools/javac/api/6406133/T6406133.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6406133/T6406133.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -27,6 +27,8 @@
* @summary Compiler API ignores locale settings
* @author Maurizio Cimadamore
* @library ../lib
+ * @build ToolTester
+ * @run main T6406133
*/
import javax.tools.*;
--- a/langtools/test/tools/javac/api/6410643/T6410643.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6410643/T6410643.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
* @summary JSR 199: The method JavaCompilerTool.run fails to handle null arguments
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
+ * @run main T6410643
*/
import javax.tools.JavaFileObject;
--- a/langtools/test/tools/javac/api/6411310/T6411310.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6411310/T6411310.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary JSR 199: FileObject should support user-friendly names via getName()
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6411310.java
* @run main T6411310
*/
--- a/langtools/test/tools/javac/api/6411333/T6411333.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6411333/T6411333.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary Ensure 6400208, 6400225, and 6400267 are tested
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6411333.java
* @run main T6411333
*/
--- a/langtools/test/tools/javac/api/6412656/T6412656.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6412656/T6412656.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
* @summary JSR 199: pass annotation processor instances to compiler
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
+ * @run main T6412656
*/
import java.util.Set;
--- a/langtools/test/tools/javac/api/6415780/T6415780.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6415780/T6415780.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -28,6 +28,8 @@
* @author igor.tseytin@...
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
+ * @run main T6415780
*/
import static javax.tools.StandardLocation.CLASS_PATH;
--- a/langtools/test/tools/javac/api/6418694/T6418694.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6418694/T6418694.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary JSR 199: JavaFileManager.hasLocation(Location)
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6418694.java
* @run main T6418694
*/
--- a/langtools/test/tools/javac/api/6421111/T6421111.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6421111/T6421111.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary NullPointerException thrown when retrieving bounds for the type parameter
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile -Xlint:all T6421111.java
* @run main T6421111
*/
--- a/langtools/test/tools/javac/api/6421756/T6421756.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6421756/T6421756.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary 6421756 JSR 199: In the method JavaCompilerTool.getTask 'options' can be supplied in the place of 'classes'
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6421756.java
* @run main T6421756
*/
--- a/langtools/test/tools/javac/api/6422215/T6422215.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6422215/T6422215.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
* @summary JSR 199: What happens if a directory is missing
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
+ * @run main T6422215
*/
import java.io.File;
--- a/langtools/test/tools/javac/api/6422327/T6422327.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6422327/T6422327.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
* @summary JSR 199: JavaCompilerTool can compile and generate '.class' of non '.java' files
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
+ * @run main T6422327
*/
import java.io.File;
--- a/langtools/test/tools/javac/api/6423003/T6423003.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6423003/T6423003.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary JSR 199: confusing help message with compiler API
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6423003.java
* @run main T6423003
*/
--- a/langtools/test/tools/javac/api/6431257/T6431257.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6431257/T6431257.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6431257.java package-info.java
* @run main T6431257 foo.bar.baz foo/bar/baz
*/
--- a/langtools/test/tools/javac/api/6437349/T6437349.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6437349/T6437349.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -26,6 +26,7 @@
* @bug 6437349
* @summary JSR 199: JavaFileObject.isNameCompatible() will give true with some incompatible kinds
* @library ../lib
+ * @build ToolTester
* @compile T6437349.java
* @run main T6437349
*/
--- a/langtools/test/tools/javac/api/6437999/T6437999.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6437999/T6437999.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary Unit test for encoding argument to standard file manager
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6437999.java
* @run main T6437999
*/
--- a/langtools/test/tools/javac/api/6440333/T6440333.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6440333/T6440333.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary SimpleJavaFileObject.toString() generates URI with some extra message
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6440333.java
* @run main T6440333
*/
--- a/langtools/test/tools/javac/api/6440528/T6440528.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6440528/T6440528.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary javac deposits package-info.class in bogus directory
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6440528.java
* @run main T6440528
*/
--- a/langtools/test/tools/javac/api/6468404/T6468404.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6468404/T6468404.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -28,6 +28,7 @@
* @author jesse.glick@...
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @build ToolTester
* @compile T6468404.java
* @run main T6468404
*/
--- a/langtools/test/tools/javac/api/6731573/T6731573.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6731573/T6731573.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -27,6 +27,8 @@
* @summary diagnostic output should optionally include source line
* @author Maurizio Cimadamore
* @library ../lib
+ * @build ToolTester
+ * @run main T6731573
*/
import java.io.*;
--- a/langtools/test/tools/javac/api/6733837/T6733837.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/6733837/T6733837.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -27,6 +27,8 @@
* @summary Compiler API ignores locale settings
* @author Maurizio Cimadamore
* @library ../lib
+ * @build ToolTester
+ * @run main T6733837
*/
import java.io.StringWriter;
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java Sun May 12 18:18:54 2013 -0700
@@ -27,6 +27,7 @@
* @summary Additional functionality test of task and JSR 269
* @author Peter von der Ah\u00e9
* @library ./lib
+ * @build ToolTester
* @run main TestJavacTaskScanner TestJavacTaskScanner.java
*/
@@ -160,7 +161,7 @@
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding);
try {
fm.setLocation(SOURCE_PATH, Arrays.asList(test_src));
- fm.setLocation(CLASS_PATH, Arrays.asList(test_classes, javac_classes));
+ fm.setLocation(CLASS_PATH, join(test_class_path, Arrays.asList(javac_classes)));
fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
} catch (IOException e) {
throw new AssertionError(e);
--- a/langtools/test/tools/javac/api/guide/Test.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/guide/Test.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
* @summary Various bugs fixed while writing Compiler API Guide
* @author Peter von der Ah\u0081
* @library ../lib
+ * @build ToolTester
* @compile Test.java
* @run main Test
*/
--- a/langtools/test/tools/javac/api/lib/ToolTester.java Fri May 10 14:31:42 2013 -0700
+++ b/langtools/test/tools/javac/api/lib/ToolTester.java Sun May 12 18:18:54 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -24,7 +24,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
-import java.util.Arrays;
+import java.util.*;
import javax.tools.*;
import static javax.tools.StandardLocation.CLASS_PATH;
@@ -34,6 +34,8 @@
public class ToolTester {
public final File test_src = new File(System.getProperty("test.src", "."));
public final File test_classes = new File(System.getProperty("test.classes", "."));
+ public final List<File> test_class_path = pathToFiles(System.getProperty("test.class.path"),
+ Arrays.asList(test_classes));
public final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
public final StandardJavaFileManager fm = getFileManager(tool, null, null);
public JavaCompiler.CompilationTask task = null;
@@ -43,11 +45,36 @@
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding);
try {
fm.setLocation(SOURCE_PATH, Arrays.asList(test_src));
- fm.setLocation(CLASS_PATH, Arrays.asList(test_classes));
+ fm.setLocation(CLASS_PATH, test_class_path);
fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
} catch (IOException e) {
throw new AssertionError(e);
}
return fm;
}
+
+ protected List<File> pathToFiles(String path, List<File> defaultPath) {
+ List<File> files = new ArrayList<>();
+ for (String f: path.split(File.pathSeparator)) {
+ if (f.isEmpty())
+ continue;
+ File file = new File(f);
+ if (file.exists())
+ files.add(file);
+ }
+ if (files.isEmpty())
+ files.addAll(defaultPath);
+ return files;
+ }
+
+ protected <T> List<T> join(List<T> a, List<T> b) {
+ if (a.isEmpty())
+ return b;
+ if (b.isEmpty())
+ return a;
+ List<T> result = new ArrayList<>();
+ result.addAll(a);
+ result.addAll(b);
+ return result;
+ }
}