test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath

test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java

Print this page




  73         moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
  74         moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
  75 
  76         Path srcJar = moduleDir.resolve(TEST_MODULE1 + ".jar");
  77         destJar = moduleDir2.resolve(TEST_MODULE1 + ".jar");
  78         String classes = MODS_DIR.resolve(TEST_MODULE1).toString();
  79         JarBuilder.createModularJar(srcJar.toString(), classes, MAIN_CLASS);
  80         Files.copy(srcJar, destJar);
  81 
  82     }
  83 
  84     public static void main(String... args) throws Exception {
  85         // compile the modules and create the modular jar files
  86         buildTestModule();
  87         String appClasses[] = {MAIN_CLASS};
  88         // create an archive with both -cp and --module-path in the command line.
  89         // Only the class in the modular jar in the --module-path will be archived;
  90         // the class in the modular jar in the -cp won't be archived.
  91         OutputAnalyzer output = TestCommon.createArchive(
  92                                         destJar.toString(), appClasses,
  93                                         "-Xlog:class+load=trace",
  94                                         "--module-path", moduleDir.toString(),
  95                                         "-m", TEST_MODULE1);
  96         TestCommon.checkDump(output);
  97 
  98         // run with the archive using the same command line as in dump time.
  99         // The main class should be loaded from the archive.
 100         TestCommon.run("-Xlog:class+load=trace",
 101                        "-cp", destJar.toString(),
 102                        "--module-path", moduleDir.toString(),
 103                        "-m", TEST_MODULE1)
 104             .assertNormalExit("[class,load] com.simple.Main source: shared objects file");
 105 
 106         // run with the archive with the main class name inserted before the -m.
 107         // The main class name will be picked up before the module name. So the
 108         // main class should be loaded from the jar in the -cp.
 109         TestCommon.run("-Xlog:class+load=trace",
 110                        "-cp", destJar.toString(),
 111                        "--module-path", moduleDir.toString(),
 112                        MAIN_CLASS, "-m", TEST_MODULE1)
 113             .assertNormalExit(out ->


 152                    .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar");
 153             });
 154         // run with the archive with the --patch-module option.
 155         // CDS will be disabled with this options and the main class will be
 156         // loaded from the modular jar.
 157         TestCommon.run("-Xlog:class+load=trace",
 158                        "-cp", destJar.toString(),
 159                        "--patch-module", TEST_MODULE1 + "=" + MODS_DIR.toString(),
 160                        "--module-path", moduleDir.toString(),
 161                        "-m", TEST_MODULE1)
 162             .assertSilentlyDisabledCDS(out -> {
 163                 out.shouldHaveExitValue(0)
 164                    .shouldMatch("CDS is disabled when the.*option is specified")
 165                    .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar");
 166             });
 167         // modify the timestamp of the jar file
 168         (new File(destJar.toString())).setLastModified(System.currentTimeMillis() + 2000);
 169         // run with the archive and the jar with modified timestamp.
 170         // It should fail due to timestamp of the jar doesn't match the one
 171         // used during dump time.
 172         TestCommon.run("-Xlog:class+load=trace",
 173                        "-cp", destJar.toString(),
 174                        "--module-path", moduleDir.toString(),
 175                        "-m", TEST_MODULE1)
 176             .assertAbnormalExit(
 177                 "A jar file is not the one used while building the shared archive file:");
 178         // create an archive with a non-empty directory in the --module-path.
 179         // The dumping process will exit with an error due to non-empty directory
 180         // in the --module-path.
 181         output = TestCommon.createArchive(destJar.toString(), appClasses,
 182                                           "--module-path", MODS_DIR.toString(),
 183                                           "-m", TEST_MODULE1);
 184         output.shouldHaveExitValue(1)
 185               .shouldMatch("Error: non-empty directory.*com.simple");
 186 
 187         // test module path with very long length
 188         //
 189         // This test can't be run on the windows platform due to an existing
 190         // issue in ClassLoader::get_canonical_path() (JDK-8190737).
 191         if (Platform.isWindows()) {
 192             System.out.println("Long module path test cannot be tested on the Windows platform.");
 193             return;




  73         moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
  74         moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
  75 
  76         Path srcJar = moduleDir.resolve(TEST_MODULE1 + ".jar");
  77         destJar = moduleDir2.resolve(TEST_MODULE1 + ".jar");
  78         String classes = MODS_DIR.resolve(TEST_MODULE1).toString();
  79         JarBuilder.createModularJar(srcJar.toString(), classes, MAIN_CLASS);
  80         Files.copy(srcJar, destJar);
  81 
  82     }
  83 
  84     public static void main(String... args) throws Exception {
  85         // compile the modules and create the modular jar files
  86         buildTestModule();
  87         String appClasses[] = {MAIN_CLASS};
  88         // create an archive with both -cp and --module-path in the command line.
  89         // Only the class in the modular jar in the --module-path will be archived;
  90         // the class in the modular jar in the -cp won't be archived.
  91         OutputAnalyzer output = TestCommon.createArchive(
  92                                         destJar.toString(), appClasses,

  93                                         "--module-path", moduleDir.toString(),
  94                                         "-m", TEST_MODULE1);
  95         TestCommon.checkDump(output);
  96 
  97         // run with the archive using the same command line as in dump time.
  98         // The main class should be loaded from the archive.
  99         TestCommon.run("-Xlog:class+load=trace",
 100                        "-cp", destJar.toString(),
 101                        "--module-path", moduleDir.toString(),
 102                        "-m", TEST_MODULE1)
 103             .assertNormalExit("[class,load] com.simple.Main source: shared objects file");
 104 
 105         // run with the archive with the main class name inserted before the -m.
 106         // The main class name will be picked up before the module name. So the
 107         // main class should be loaded from the jar in the -cp.
 108         TestCommon.run("-Xlog:class+load=trace",
 109                        "-cp", destJar.toString(),
 110                        "--module-path", moduleDir.toString(),
 111                        MAIN_CLASS, "-m", TEST_MODULE1)
 112             .assertNormalExit(out ->


 151                    .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar");
 152             });
 153         // run with the archive with the --patch-module option.
 154         // CDS will be disabled with this options and the main class will be
 155         // loaded from the modular jar.
 156         TestCommon.run("-Xlog:class+load=trace",
 157                        "-cp", destJar.toString(),
 158                        "--patch-module", TEST_MODULE1 + "=" + MODS_DIR.toString(),
 159                        "--module-path", moduleDir.toString(),
 160                        "-m", TEST_MODULE1)
 161             .assertSilentlyDisabledCDS(out -> {
 162                 out.shouldHaveExitValue(0)
 163                    .shouldMatch("CDS is disabled when the.*option is specified")
 164                    .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar");
 165             });
 166         // modify the timestamp of the jar file
 167         (new File(destJar.toString())).setLastModified(System.currentTimeMillis() + 2000);
 168         // run with the archive and the jar with modified timestamp.
 169         // It should fail due to timestamp of the jar doesn't match the one
 170         // used during dump time.
 171         TestCommon.run("-cp", destJar.toString(),

 172                        "--module-path", moduleDir.toString(),
 173                        "-m", TEST_MODULE1)
 174             .assertAbnormalExit(
 175                 "A jar file is not the one used while building the shared archive file:");
 176         // create an archive with a non-empty directory in the --module-path.
 177         // The dumping process will exit with an error due to non-empty directory
 178         // in the --module-path.
 179         output = TestCommon.createArchive(destJar.toString(), appClasses,
 180                                           "--module-path", MODS_DIR.toString(),
 181                                           "-m", TEST_MODULE1);
 182         output.shouldHaveExitValue(1)
 183               .shouldMatch("Error: non-empty directory.*com.simple");
 184 
 185         // test module path with very long length
 186         //
 187         // This test can't be run on the windows platform due to an existing
 188         // issue in ClassLoader::get_canonical_path() (JDK-8190737).
 189         if (Platform.isWindows()) {
 190             System.out.println("Long module path test cannot be tested on the Windows platform.");
 191             return;


test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File