< prev index next >

langtools/test/tools/javac/modules/ModulePathTest.java

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary tests for --module-path
  27  * @library /tools/lib
  28  * @modules
  29  *      jdk.compiler/com.sun.tools.javac.api
  30  *      jdk.compiler/com.sun.tools.javac.main
  31  *      jdk.jdeps/com.sun.tools.javap
  32  *      jdk.jlink/jdk.tools.jmod
  33  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.ModuleBuilder
  34  *      ModuleTestBase
  35  * @run main ModulePathTest
  36  */
  37 
  38 import java.io.File;
  39 import java.io.IOException;
  40 import java.nio.file.Files;
  41 import java.nio.file.Path;

  42 
  43 import toolbox.JarTask;
  44 import toolbox.JavacTask;
  45 import toolbox.ModuleBuilder;
  46 import toolbox.Task;
  47 import toolbox.ToolBox;
  48 
  49 public class ModulePathTest extends ModuleTestBase {
  50 
  51     public static final String PATH_SEP = File.pathSeparator;
  52 
  53     public static void main(String... args) throws Exception {
  54         ModulePathTest t = new ModulePathTest();
  55         t.runTests();
  56     }
  57 
  58     @Test
  59     public void testNotExistsOnPath(Path base) throws Exception {
  60         Path src = base.resolve("src");
  61         tb.writeJavaFiles(src, "class C { }");


 403                         "--module-path", modules.toString())
 404                 .files(findJavaFiles(src))
 405                 .run()
 406                 .writeAll();
 407     }
 408 
 409     private void jar(Path dir, Path jar) throws IOException {
 410         new JarTask(tb, jar)
 411                 .baseDir(dir)
 412                 .files(".")
 413                 .run()
 414                 .writeAll();
 415     }
 416 
 417     private void jmod(Path dir, Path jmod) throws Exception {
 418         String[] args = {
 419                 "create",
 420                 "--class-path", dir.toString(),
 421                 jmod.toString()
 422         };
 423         jdk.tools.jmod.Main.run(args, System.out);



 424     }
 425 }


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary tests for --module-path
  27  * @library /tools/lib
  28  * @modules
  29  *      jdk.compiler/com.sun.tools.javac.api
  30  *      jdk.compiler/com.sun.tools.javac.main
  31  *      jdk.jdeps/com.sun.tools.javap
  32  *      jdk.jlink
  33  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.ModuleBuilder
  34  *      ModuleTestBase
  35  * @run main ModulePathTest
  36  */
  37 
  38 import java.io.File;
  39 import java.io.IOException;
  40 import java.nio.file.Files;
  41 import java.nio.file.Path;
  42 import java.util.spi.ToolProvider;
  43 
  44 import toolbox.JarTask;
  45 import toolbox.JavacTask;
  46 import toolbox.ModuleBuilder;
  47 import toolbox.Task;
  48 import toolbox.ToolBox;
  49 
  50 public class ModulePathTest extends ModuleTestBase {
  51 
  52     public static final String PATH_SEP = File.pathSeparator;
  53 
  54     public static void main(String... args) throws Exception {
  55         ModulePathTest t = new ModulePathTest();
  56         t.runTests();
  57     }
  58 
  59     @Test
  60     public void testNotExistsOnPath(Path base) throws Exception {
  61         Path src = base.resolve("src");
  62         tb.writeJavaFiles(src, "class C { }");


 404                         "--module-path", modules.toString())
 405                 .files(findJavaFiles(src))
 406                 .run()
 407                 .writeAll();
 408     }
 409 
 410     private void jar(Path dir, Path jar) throws IOException {
 411         new JarTask(tb, jar)
 412                 .baseDir(dir)
 413                 .files(".")
 414                 .run()
 415                 .writeAll();
 416     }
 417 
 418     private void jmod(Path dir, Path jmod) throws Exception {
 419         String[] args = {
 420                 "create",
 421                 "--class-path", dir.toString(),
 422                 jmod.toString()
 423         };
 424         ToolProvider jmodTool = ToolProvider.findFirst("jmod").orElseThrow(() ->
 425                 new RuntimeException("jmod tool not found")
 426         );
 427         jmodTool.run(System.out, System.out, args);
 428     }
 429 }
< prev index next >