Test ReleaseOptionCurrent.java writes ReleaseOption.class in the source directory

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu May 17 14:27:50 UTC 2018


Bernard,

Since you are using classes in the current directory, you do not need to 
clean the directory (jtreg runs tests in an empty directory) nor do you 
need to create the directory (javac now does that).

-- Jon


On 5/17/18 5:39 AM, B. Blaser wrote:
> Hi,
>
> Test ReleaseOptionCurrent.java writes ReleaseOption.class in the
> source directory.
> Next is a quick fix for this.
> Any feedback is welcome.
>
> Cheers,
> Bernard
>
>
> diff -r 8e4fcfb4cfe4
> test/langtools/tools/javac/options/release/ReleaseOptionCurrent.java
> --- a/test/langtools/tools/javac/options/release/ReleaseOptionCurrent.java
>     Thu May 17 10:32:26 2018 +0200
> +++ b/test/langtools/tools/javac/options/release/ReleaseOptionCurrent.java
>     Thu May 17 14:17:52 2018 +0200
> @@ -25,10 +25,14 @@
>    * @test
>    * @bug 8202387
>    * @summary Verify that javac can handle --release <current>
> + * @library /tools/lib
>    * @modules jdk.compiler/com.sun.tools.javac.code
>    */
>
>   import java.io.IOException;
> +import java.nio.file.Files;
> +import java.nio.file.Path;
> +import java.nio.file.Paths;
>   import java.util.Arrays;
>   import java.util.List;
>   import javax.tools.JavaCompiler;
> @@ -38,18 +42,29 @@
>
>   import com.sun.tools.javac.code.Source;
>
> +import toolbox.ToolBox;
> +
>   public class ReleaseOptionCurrent {
>       public static void main(String... args) throws IOException {
>           new ReleaseOptionCurrent().run();
>       }
>
> +    private final ToolBox tb = new ToolBox();
> +
>       void run() throws IOException {
>           String lineSep = System.getProperty("line.separator");
> +        Path classes = Paths.get("classes");
> +
> +        if (Files.exists(classes)) {
> +            tb.cleanDirectory(classes);
> +        } else {
> +            Files.createDirectories(classes);
> +        }
>           JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
>           try (StandardJavaFileManager fm =
> compiler.getStandardFileManager(null, null, null)) {
>               Iterable<? extends JavaFileObject> input =
>
> fm.getJavaFileObjects(System.getProperty("test.src") +
> "/ReleaseOption.java");
> -            List<String> options = Arrays.asList("--release",
> Source.DEFAULT.name);
> +            List<String> options = Arrays.asList("-d",
> classes.toString(), "--release", Source.DEFAULT.name);
>
>               boolean result = compiler.getTask(null, fm, null,
> options, null, input).call();
>               if (!result) {



More information about the compiler-dev mailing list