langtools/test/tools/javac/modules/NPEEmptyFileTest.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
child 37758 3ecf9b414e05
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    26  * @summary NPE while compiling empty javafile with -modulesourcepath option
    26  * @summary NPE while compiling empty javafile with -modulesourcepath option
    27  * @library /tools/lib
    27  * @library /tools/lib
    28  * @modules
    28  * @modules
    29  *      jdk.compiler/com.sun.tools.javac.api
    29  *      jdk.compiler/com.sun.tools.javac.api
    30  *      jdk.compiler/com.sun.tools.javac.main
    30  *      jdk.compiler/com.sun.tools.javac.main
    31  *      jdk.jdeps/com.sun.tools.javap
    31  * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
    32  * @build ToolBox ModuleTestBase
       
    33  * @run main NPEEmptyFileTest
    32  * @run main NPEEmptyFileTest
    34  */
    33  */
    35 
    34 
    36 import java.nio.file.Files;
    35 import java.nio.file.Files;
    37 import java.nio.file.Path;
    36 import java.nio.file.Path;
       
    37 
       
    38 import toolbox.JavacTask;
       
    39 import toolbox.Task;
       
    40 import toolbox.ToolBox;
    38 
    41 
    39 public class NPEEmptyFileTest extends ModuleTestBase {
    42 public class NPEEmptyFileTest extends ModuleTestBase {
    40     public static void main(String... args) throws Exception {
    43     public static void main(String... args) throws Exception {
    41         new NPEEmptyFileTest().runTests();
    44         new NPEEmptyFileTest().runTests();
    42     }
    45     }
    45     void compileEmptyFile(Path base) throws Exception {
    48     void compileEmptyFile(Path base) throws Exception {
    46         Path modules = base.resolve("modules");
    49         Path modules = base.resolve("modules");
    47         Files.createDirectories(modules);
    50         Files.createDirectories(modules);
    48         Path emptyJavaFile = base.resolve("Test.java");
    51         Path emptyJavaFile = base.resolve("Test.java");
    49         tb.writeFile(emptyJavaFile, "");
    52         tb.writeFile(emptyJavaFile, "");
    50         tb.new JavacTask(ToolBox.Mode.EXEC)
    53         new JavacTask(tb, Task.Mode.EXEC)
    51                 .options("-modulesourcepath", modules.toString(),
    54                 .options("-modulesourcepath", modules.toString(),
    52                         "-d", modules.toString(), emptyJavaFile.toString())
    55                         "-d", modules.toString(), emptyJavaFile.toString())
    53                 .run()
    56                 .run()
    54                 .writeAll();
    57                 .writeAll();
    55     }
    58     }