langtools/test/tools/javac/ExtDirs/ExtDirTest.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 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.
    25  * @test
    25  * @test
    26  * @bug 4204897 4256097 4785453 4863609
    26  * @bug 4204897 4256097 4785453 4863609
    27  * @summary Test that '.jar' files in -extdirs are found.
    27  * @summary Test that '.jar' files in -extdirs are found.
    28  * @library /tools/lib
    28  * @library /tools/lib
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    30  *          jdk.compiler/com.sun.tools.javac.file
       
    31  *          jdk.compiler/com.sun.tools.javac.main
    30  *          jdk.compiler/com.sun.tools.javac.main
    32  *          jdk.jdeps/com.sun.tools.javap
    31  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
    33  * @build ToolBox
       
    34  * @run main ExtDirTest
    32  * @run main ExtDirTest
    35  */
    33  */
    36 
    34 
    37 import java.io.File;
    35 import java.io.File;
       
    36 
       
    37 import toolbox.JarTask;
       
    38 import toolbox.JavacTask;
       
    39 import toolbox.ToolBox;
    38 
    40 
    39 // Original test: test/tools/javac/ExtDirs/ExtDirs.sh
    41 // Original test: test/tools/javac/ExtDirs/ExtDirs.sh
    40 public class ExtDirTest {
    42 public class ExtDirTest {
    41 
    43 
    42     private static final String ExtDirTestClass1Src =
    44     private static final String ExtDirTestClass1Src =
   110         createJars();
   112         createJars();
   111         compileWithExtDirs();
   113         compileWithExtDirs();
   112     }
   114     }
   113 
   115 
   114     void createJars() throws Exception {
   116     void createJars() throws Exception {
   115         tb.new JavacTask()
   117         new JavacTask(tb)
   116                 .outdir(".")
   118                 .outdir(".")
   117                 .sources(ExtDirTestClass1Src)
   119                 .sources(ExtDirTestClass1Src)
   118                 .run();
   120                 .run();
   119 
   121 
   120         tb.new JarTask("pkg1.jar")
   122         new JarTask(tb, "pkg1.jar")
   121                 .manifest(jar1Manifest)
   123                 .manifest(jar1Manifest)
   122                 .files("pkg1/ExtDirTestClass1.class")
   124                 .files("pkg1/ExtDirTestClass1.class")
   123                 .run();
   125                 .run();
   124 
   126 
   125         tb.new JavacTask()
   127         new JavacTask(tb)
   126                 .outdir(".")
   128                 .outdir(".")
   127                 .sources(ExtDirTestClass2Src)
   129                 .sources(ExtDirTestClass2Src)
   128                 .run();
   130                 .run();
   129 
   131 
   130         tb.new JarTask("pkg2.jar")
   132         new JarTask(tb, "pkg2.jar")
   131                 .manifest(jar2Manifest)
   133                 .manifest(jar2Manifest)
   132                 .files("pkg2/ExtDirTestClass2.class")
   134                 .files("pkg2/ExtDirTestClass2.class")
   133                 .run();
   135                 .run();
   134 
   136 
   135         tb.createDirectories("ext1", "ext2", "ext3");
   137         tb.createDirectories("ext1", "ext2", "ext3");
   147                 "pkg2"
   149                 "pkg2"
   148         );
   150         );
   149     }
   151     }
   150 
   152 
   151     void compileWithExtDirs() throws Exception {
   153     void compileWithExtDirs() throws Exception {
   152         tb.new JavacTask()
   154         new JavacTask(tb)
   153                 .outdir(".")
   155                 .outdir(".")
   154                 .options("-source", "8",
   156                 .options("-source", "8",
   155                         "-extdirs", "ext1")
   157                         "-extdirs", "ext1")
   156                 .sources(ExtDirTest_1Src)
   158                 .sources(ExtDirTest_1Src)
   157                 .run()
   159                 .run()
   158                 .writeAll();
   160                 .writeAll();
   159 
   161 
   160         tb.new JavacTask()
   162         new JavacTask(tb)
   161                 .outdir(".")
   163                 .outdir(".")
   162                 .options("-source", "8",
   164                 .options("-source", "8",
   163                         "-extdirs", "ext1" + File.pathSeparator + "ext2")
   165                         "-extdirs", "ext1" + File.pathSeparator + "ext2")
   164                 .sources(ExtDirTest_2Src)
   166                 .sources(ExtDirTest_2Src)
   165                 .run()
   167                 .run()
   166                 .writeAll();
   168                 .writeAll();
   167 
   169 
   168         tb.new JavacTask()
   170         new JavacTask(tb)
   169                 .outdir(".")
   171                 .outdir(".")
   170                 .options("-source", "8",
   172                 .options("-source", "8",
   171                         "-extdirs", "ext3")
   173                         "-extdirs", "ext3")
   172                 .sources(ExtDirTest_3Src)
   174                 .sources(ExtDirTest_3Src)
   173                 .run()
   175                 .run()