8014363: javac test class ToolTester handles classpath incorrectly

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2013-05-12 18:18:54 -07:00
parent 8ea0284b13
commit c037757e7b
23 changed files with 82 additions and 25 deletions

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary Compiler API ignores locale settings * @summary Compiler API ignores locale settings
* @author Maurizio Cimadamore * @author Maurizio Cimadamore
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6406133
*/ */
import javax.tools.*; import javax.tools.*;

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary JSR 199: The method JavaCompilerTool.run fails to handle null arguments * @summary JSR 199: The method JavaCompilerTool.run fails to handle null arguments
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6410643
*/ */
import javax.tools.JavaFileObject; import javax.tools.JavaFileObject;

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary JSR 199: FileObject should support user-friendly names via getName() * @summary JSR 199: FileObject should support user-friendly names via getName()
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6411310.java * @compile T6411310.java
* @run main T6411310 * @run main T6411310
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary Ensure 6400208, 6400225, and 6400267 are tested * @summary Ensure 6400208, 6400225, and 6400267 are tested
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6411333.java * @compile T6411333.java
* @run main T6411333 * @run main T6411333
*/ */

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary JSR 199: pass annotation processor instances to compiler * @summary JSR 199: pass annotation processor instances to compiler
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6412656
*/ */
import java.util.Set; import java.util.Set;

View file

@ -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. * 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
@ -28,6 +28,8 @@
* @author igor.tseytin@... * @author igor.tseytin@...
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6415780
*/ */
import static javax.tools.StandardLocation.CLASS_PATH; import static javax.tools.StandardLocation.CLASS_PATH;

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary JSR 199: JavaFileManager.hasLocation(Location) * @summary JSR 199: JavaFileManager.hasLocation(Location)
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6418694.java * @compile T6418694.java
* @run main T6418694 * @run main T6418694
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary NullPointerException thrown when retrieving bounds for the type parameter * @summary NullPointerException thrown when retrieving bounds for the type parameter
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile -Xlint:all T6421111.java * @compile -Xlint:all T6421111.java
* @run main T6421111 * @run main T6421111
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary 6421756 JSR 199: In the method JavaCompilerTool.getTask 'options' can be supplied in the place of 'classes' * @summary 6421756 JSR 199: In the method JavaCompilerTool.getTask 'options' can be supplied in the place of 'classes'
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6421756.java * @compile T6421756.java
* @run main T6421756 * @run main T6421756
*/ */

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary JSR 199: What happens if a directory is missing * @summary JSR 199: What happens if a directory is missing
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6422215
*/ */
import java.io.File; import java.io.File;

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary JSR 199: JavaCompilerTool can compile and generate '.class' of non '.java' files * @summary JSR 199: JavaCompilerTool can compile and generate '.class' of non '.java' files
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6422327
*/ */
import java.io.File; import java.io.File;

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary JSR 199: confusing help message with compiler API * @summary JSR 199: confusing help message with compiler API
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6423003.java * @compile T6423003.java
* @run main T6423003 * @run main T6423003
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API * @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6431257.java package-info.java * @compile T6431257.java package-info.java
* @run main T6431257 foo.bar.baz foo/bar/baz * @run main T6431257 foo.bar.baz foo/bar/baz
*/ */

View file

@ -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. * 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
@ -26,6 +26,7 @@
* @bug 6437349 * @bug 6437349
* @summary JSR 199: JavaFileObject.isNameCompatible() will give true with some incompatible kinds * @summary JSR 199: JavaFileObject.isNameCompatible() will give true with some incompatible kinds
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6437349.java * @compile T6437349.java
* @run main T6437349 * @run main T6437349
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary Unit test for encoding argument to standard file manager * @summary Unit test for encoding argument to standard file manager
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6437999.java * @compile T6437999.java
* @run main T6437999 * @run main T6437999
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary SimpleJavaFileObject.toString() generates URI with some extra message * @summary SimpleJavaFileObject.toString() generates URI with some extra message
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6440333.java * @compile T6440333.java
* @run main T6440333 * @run main T6440333
*/ */

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary javac deposits package-info.class in bogus directory * @summary javac deposits package-info.class in bogus directory
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6440528.java * @compile T6440528.java
* @run main T6440528 * @run main T6440528
*/ */

View file

@ -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. * 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
@ -28,6 +28,7 @@
* @author jesse.glick@... * @author jesse.glick@...
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../lib * @library ../lib
* @build ToolTester
* @compile T6468404.java * @compile T6468404.java
* @run main T6468404 * @run main T6468404
*/ */

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary diagnostic output should optionally include source line * @summary diagnostic output should optionally include source line
* @author Maurizio Cimadamore * @author Maurizio Cimadamore
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6731573
*/ */
import java.io.*; import java.io.*;

View file

@ -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. * 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
@ -27,6 +27,8 @@
* @summary Compiler API ignores locale settings * @summary Compiler API ignores locale settings
* @author Maurizio Cimadamore * @author Maurizio Cimadamore
* @library ../lib * @library ../lib
* @build ToolTester
* @run main T6733837
*/ */
import java.io.StringWriter; import java.io.StringWriter;

View file

@ -27,6 +27,7 @@
* @summary Additional functionality test of task and JSR 269 * @summary Additional functionality test of task and JSR 269
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ./lib * @library ./lib
* @build ToolTester
* @run main TestJavacTaskScanner TestJavacTaskScanner.java * @run main TestJavacTaskScanner TestJavacTaskScanner.java
*/ */
@ -160,7 +161,7 @@ public class TestJavacTaskScanner extends ToolTester {
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding);
try { try {
fm.setLocation(SOURCE_PATH, Arrays.asList(test_src)); 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)); fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
} catch (IOException e) { } catch (IOException e) {
throw new AssertionError(e); throw new AssertionError(e);

View file

@ -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. * 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
@ -27,6 +27,7 @@
* @summary Various bugs fixed while writing Compiler API Guide * @summary Various bugs fixed while writing Compiler API Guide
* @author Peter von der Ah\u0081 * @author Peter von der Ah\u0081
* @library ../lib * @library ../lib
* @build ToolTester
* @compile Test.java * @compile Test.java
* @run main Test * @run main Test
*/ */

View file

@ -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. * 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
@ -24,7 +24,7 @@
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Arrays; import java.util.*;
import javax.tools.*; import javax.tools.*;
import static javax.tools.StandardLocation.CLASS_PATH; import static javax.tools.StandardLocation.CLASS_PATH;
@ -34,6 +34,8 @@ import static javax.tools.StandardLocation.CLASS_OUTPUT;
public class ToolTester { public class ToolTester {
public final File test_src = new File(System.getProperty("test.src", ".")); public final File test_src = new File(System.getProperty("test.src", "."));
public final File test_classes = new File(System.getProperty("test.classes", ".")); 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 JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
public final StandardJavaFileManager fm = getFileManager(tool, null, null); public final StandardJavaFileManager fm = getFileManager(tool, null, null);
public JavaCompiler.CompilationTask task = null; public JavaCompiler.CompilationTask task = null;
@ -43,11 +45,36 @@ public class ToolTester {
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding);
try { try {
fm.setLocation(SOURCE_PATH, Arrays.asList(test_src)); 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)); fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
} catch (IOException e) { } catch (IOException e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
return fm; 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;
}
} }