< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java

Print this page


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 /**
  26  * @test
  27  * @requires vm.cds & !vm.jvmci
  28  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
  29  * @run driver OptimizeModuleHandlingTest
  30  * @summary test module path changes for optimization of
  31  *          module handling.
  32  *
  33  */
  34 
  35 import java.io.File;
  36 import java.nio.file.Files;
  37 import java.nio.file.Path;
  38 import java.nio.file.Paths;
  39 
  40 import jdk.test.lib.process.OutputAnalyzer;
  41 
  42 public class OptimizeModuleHandlingTest {
  43 
  44     private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
  45 
  46     private static final String TEST_SRC = System.getProperty("test.src");
  47 
  48     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
  49     private static final Path MODS_DIR = Paths.get("mody");
  50 
  51     // the module name of the test module
  52     private static final String MAIN_MODULE = "com.bars";
  53     private static final String TEST_MODULE = "com.foos";
  54 
  55     // the module main class
  56     private static final String MAIN_CLASS = "com.bars.Main";
  57     private static final String TEST_CLASS = "com.foos.Test";
  58 
  59     private static String PATH_LIBS = "modylibs";
  60     private static Path libsDir = null;
  61     private static Path mainJar = null;
  62     private static Path testJar = null;
  63 
  64     private static String CLASS_FOUND_MESSAGE = "com.foos.Test found";
  65     private static String CLASS_NOT_FOUND_MESSAGE = "java.lang.ClassNotFoundException: com.foos.Test";
  66     private static String OPTIMIZE_ENABLED = "Using optimized module handling enabled";
  67     private static String OPTIMIZE_DISABLED = "Using optimized module handling disabled";
  68     private static String MAIN_FROM_JAR = "class,load.*com.bars.Main.*[.]jar";
  69     private static String MAIN_FROM_CDS = "class,load.*com.bars.Main.*shared objects file";
  70     private static String TEST_FROM_JAR = "class,load.*com.foos.Test.*[.]jar";
  71     private static String TEST_FROM_CDS = "class,load.*com.foos.Test.*shared objects file";
  72     private static String MAP_FAILED  = "Unable to use shared archive";
  73     private static String PATH_SEPARATOR = File.pathSeparator;
  74 
  75     public static void buildTestModule() throws Exception {
  76 
  77         // javac -d mods/$TESTMODULE src/$TESTMODULE/**
  78         JarBuilder.compileModule(SRC_DIR.resolve(TEST_MODULE),
  79                                  MODS_DIR.resolve(TEST_MODULE),
  80                                  null);
  81 
  82         // javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/**
  83         JarBuilder.compileModule(SRC_DIR.resolve(MAIN_MODULE),
  84                                  MODS_DIR.resolve(MAIN_MODULE),
  85                                  MODS_DIR.toString());
  86 
  87         libsDir = Files.createTempDirectory(USER_DIR, PATH_LIBS);




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 /**
  26  * @test
  27  * @requires vm.cds & !vm.graal.enabled
  28  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
  29  * @run driver OptimizeModuleHandlingTest
  30  * @summary test module path changes for optimization of
  31  *          module handling.
  32  *
  33  */
  34 
  35 import java.io.File;
  36 import java.nio.file.Files;
  37 import java.nio.file.Path;
  38 import java.nio.file.Paths;
  39 
  40 import jdk.test.lib.process.OutputAnalyzer;
  41 
  42 public class OptimizeModuleHandlingTest {
  43 
  44     private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
  45 
  46     private static final String TEST_SRC = System.getProperty("test.src");
  47 
  48     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
  49     private static final Path MODS_DIR = Paths.get("mody");
  50 
  51     // the module name of the test module
  52     private static final String MAIN_MODULE = "com.bars";
  53     private static final String TEST_MODULE = "com.foos";
  54 
  55     // the module main class
  56     private static final String MAIN_CLASS = "com.bars.Main";
  57     private static final String TEST_CLASS = "com.foos.Test";
  58 
  59     private static String PATH_LIBS = "modylibs";
  60     private static Path libsDir = null;
  61     private static Path mainJar = null;
  62     private static Path testJar = null;
  63 
  64     private static String CLASS_FOUND_MESSAGE = "com.foos.Test found";
  65     private static String CLASS_NOT_FOUND_MESSAGE = "java.lang.ClassNotFoundException: com.foos.Test";
  66     private static String OPTIMIZE_ENABLED = "optimized module handling: enabled";
  67     private static String OPTIMIZE_DISABLED = "optimized module handling: disabled";
  68     private static String MAIN_FROM_JAR = "class,load.*com.bars.Main.*[.]jar";
  69     private static String MAIN_FROM_CDS = "class,load.*com.bars.Main.*shared objects file";
  70     private static String TEST_FROM_JAR = "class,load.*com.foos.Test.*[.]jar";
  71     private static String TEST_FROM_CDS = "class,load.*com.foos.Test.*shared objects file";
  72     private static String MAP_FAILED  = "Unable to use shared archive";
  73     private static String PATH_SEPARATOR = File.pathSeparator;
  74 
  75     public static void buildTestModule() throws Exception {
  76 
  77         // javac -d mods/$TESTMODULE src/$TESTMODULE/**
  78         JarBuilder.compileModule(SRC_DIR.resolve(TEST_MODULE),
  79                                  MODS_DIR.resolve(TEST_MODULE),
  80                                  null);
  81 
  82         // javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/**
  83         JarBuilder.compileModule(SRC_DIR.resolve(MAIN_MODULE),
  84                                  MODS_DIR.resolve(MAIN_MODULE),
  85                                  MODS_DIR.toString());
  86 
  87         libsDir = Files.createTempDirectory(USER_DIR, PATH_LIBS);


< prev index next >