test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.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/ModulePathAndCP.java

Print this page




  86         Files.copy(subJar, destJar);
  87 
  88         mainJar = moduleDir.resolve(MAIN_MODULE + ".jar");
  89         Path mainJar2 = moduleDir2.resolve(MAIN_MODULE + ".jar");
  90         classes = MODS_DIR.resolve(MAIN_MODULE).toString();
  91         JarBuilder.createModularJar(mainJar.toString(), classes, MAIN_CLASS);
  92         Files.copy(mainJar, mainJar2);
  93 
  94     }
  95 
  96     public static void main(String... args) throws Exception {
  97         // compile the modules and create the modular jar files
  98         buildTestModule();
  99         String appClasses[] = {MAIN_CLASS, APP_CLASS};
 100         // create an archive with the classes in the modules built in the
 101         // previous step
 102         OutputAnalyzer output = TestCommon.createArchive(
 103                                         null, appClasses,
 104                                         "--module-path", moduleDir.toString(),
 105                                         "-m", MAIN_MODULE);
 106         TestCommon.checkExecReturn(output, 0, true, "Loading classes to share");
 107         String prefix[] = {"-cp", "\"\"", "-Xlog:class+load=trace"};
 108 
 109         // run with the archive with the --module-path the same as the one during
 110         // dump time. The classes should be loaded from the archive.
 111         output = TestCommon.execModule(prefix,
 112                                        null, // --upgrade-module-path
 113                                        moduleDir.toString(), // --module-path
 114                                        MAIN_MODULE); // -m
 115         TestCommon.checkExecReturn(output, 0, true,
 116               "[class,load] com.greetings.Main source: shared objects file",
 117               "[class,load] org.astro.World source: shared objects file");

 118 
 119         // run with the archive with the --module-path different from the one during
 120         // dump time. The classes should be loaded from the jar files.
 121         output = TestCommon.execModule(prefix,
 122                                        null, // --upgrade-module-path
 123                                        moduleDir2.toString(), // --module-path
 124                                        MAIN_MODULE); // -m
 125         output.shouldHaveExitValue(0)
 126               .shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar")
 127               .shouldMatch(".class.load. org.astro.World source:.*org.astro.jar");

 128 
 129         // create an archive with modular jar files in both -cp and --module-path
 130         String jars = subJar.toString() + System.getProperty("path.separator") +
 131                       mainJar.toString();
 132         output = TestCommon.createArchive( jars, appClasses,
 133                                            "-Xlog:class+load=trace", "-XX:+PrintSystemDictionaryAtExit",
 134                                            "--module-path", moduleDir.toString(),
 135                                            "-m", MAIN_MODULE);
 136         TestCommon.checkExecReturn(output, 0, true, "Loading classes to share");
 137 
 138         // run with archive with the main class name specified before
 139         // the module name with the -m option. Since the -m option was specified
 140         // during dump time, the classes in the jar files after the -cp won't be
 141         // archived. Therefore, the classes won't be loaded from the archive but
 142         // will be loaded from the jar files.
 143         output = TestCommon.execCommon( "-Xlog:class+load=trace",
 144                                         "-cp", jars,
 145                                         "--module-path", moduleDir.toString(),
 146                                         MAIN_CLASS, "-m", MAIN_MODULE);
 147         output.shouldHaveExitValue(0)
 148               .shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar")
 149               .shouldMatch(".class.load. org.astro.World source:.*org.astro.jar");


 150         // similar to the above case but without the main class name. The classes
 151         // should be loaded from the archive.                                
 152         output = TestCommon.execCommon( "-Xlog:class+load=trace",
 153                                         "-cp", jars,
 154                                         "--module-path", moduleDir.toString(),
 155                                         "-m", MAIN_MODULE);
 156         TestCommon.checkExecReturn(output, 0, true,
 157               "[class,load] com.greetings.Main source: shared objects file",
 158               "[class,load] org.astro.World source: shared objects file");
 159 
 160         // create an archive with two modular jars in the --module-path
 161         output = TestCommon.createArchive(
 162                                         null, appClasses,
 163                                         "--module-path", jars,
 164                                         "-m", MAIN_MODULE);
 165         TestCommon.checkExecReturn(output, 0, true, "Loading classes to share");
 166 
 167         // run with the above archive but with the modular jar containing the
 168         // org.astro module in a different location.
 169         // The org.astro.World class should be loaded from the jar.
 170         // The Main class should still be loaded from the archive.
 171         jars = destJar.toString() + System.getProperty("path.separator") +
 172                       mainJar.toString();
 173         output = TestCommon.execModule(prefix,
 174                                        null, // --upgrade-module-path
 175                                        jars, // --module-path
 176                                        MAIN_MODULE); // -m
 177         output.shouldHaveExitValue(0)
 178               .shouldContain("[class,load] com.greetings.Main source: shared objects file")
 179               .shouldMatch(".class.load. org.astro.World source:.*org.astro.jar");

 180     }
 181 }


  86         Files.copy(subJar, destJar);
  87 
  88         mainJar = moduleDir.resolve(MAIN_MODULE + ".jar");
  89         Path mainJar2 = moduleDir2.resolve(MAIN_MODULE + ".jar");
  90         classes = MODS_DIR.resolve(MAIN_MODULE).toString();
  91         JarBuilder.createModularJar(mainJar.toString(), classes, MAIN_CLASS);
  92         Files.copy(mainJar, mainJar2);
  93 
  94     }
  95 
  96     public static void main(String... args) throws Exception {
  97         // compile the modules and create the modular jar files
  98         buildTestModule();
  99         String appClasses[] = {MAIN_CLASS, APP_CLASS};
 100         // create an archive with the classes in the modules built in the
 101         // previous step
 102         OutputAnalyzer output = TestCommon.createArchive(
 103                                         null, appClasses,
 104                                         "--module-path", moduleDir.toString(),
 105                                         "-m", MAIN_MODULE);
 106         TestCommon.checkDump(output);
 107         String prefix[] = {"-cp", "\"\"", "-Xlog:class+load=trace"};
 108 
 109         // run with the archive with the --module-path the same as the one during
 110         // dump time. The classes should be loaded from the archive.
 111         TestCommon.runWithModules(prefix,
 112                                   null, // --upgrade-module-path
 113                                   moduleDir.toString(), // --module-path
 114                                   MAIN_MODULE) // -m
 115             .assertNormalExit(out -> {
 116                 out.shouldContain("[class,load] com.greetings.Main source: shared objects file")
 117                    .shouldContain("[class,load] org.astro.World source: shared objects file");
 118             });
 119 
 120         // run with the archive with the --module-path different from the one during
 121         // dump time. The classes should be loaded from the jar files.
 122         TestCommon.runWithModules(prefix,
 123                                   null, // --upgrade-module-path
 124                                   moduleDir2.toString(), // --module-path
 125                                   MAIN_MODULE) // -m
 126             .assertNormalExit(out -> {
 127                 out.shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar")
 128                    .shouldMatch(".class.load. org.astro.World source:.*org.astro.jar");
 129             });
 130 
 131         // create an archive with modular jar files in both -cp and --module-path
 132         String jars = subJar.toString() + System.getProperty("path.separator") +
 133                       mainJar.toString();
 134         output = TestCommon.createArchive( jars, appClasses,
 135                                            "-Xlog:class+load=trace", "-XX:+PrintSystemDictionaryAtExit",
 136                                            "--module-path", moduleDir.toString(),
 137                                            "-m", MAIN_MODULE);
 138         TestCommon.checkDump(output);
 139 
 140         // run with archive with the main class name specified before
 141         // the module name with the -m option. Since the -m option was specified
 142         // during dump time, the classes in the jar files after the -cp won't be
 143         // archived. Therefore, the classes won't be loaded from the archive but
 144         // will be loaded from the jar files.
 145         TestCommon.run("-Xlog:class+load=trace",
 146                        "-cp", jars,
 147                        "--module-path", moduleDir.toString(),
 148                        MAIN_CLASS, "-m", MAIN_MODULE)
 149             .assertNormalExit(out -> {
 150                 out.shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar")
 151                    .shouldMatch(".class.load. org.astro.World source:.*org.astro.jar");
 152             });
 153 
 154         // similar to the above case but without the main class name. The classes
 155         // should be loaded from the archive.                                
 156         TestCommon.run("-Xlog:class+load=trace",
 157                        "-cp", jars,
 158                        "--module-path", moduleDir.toString(),
 159                        "-m", MAIN_MODULE)
 160             .assertNormalExit(
 161               "[class,load] com.greetings.Main source: shared objects file",
 162               "[class,load] org.astro.World source: shared objects file");
 163 
 164         // create an archive with two modular jars in the --module-path
 165         output = TestCommon.createArchive(
 166                                         null, appClasses,
 167                                         "--module-path", jars,
 168                                         "-m", MAIN_MODULE);
 169         TestCommon.checkDump(output);
 170 
 171         // run with the above archive but with the modular jar containing the
 172         // org.astro module in a different location.
 173         // The org.astro.World class should be loaded from the jar.
 174         // The Main class should still be loaded from the archive.
 175         jars = destJar.toString() + System.getProperty("path.separator") +
 176                       mainJar.toString();
 177         TestCommon.runWithModules(prefix,
 178                                   null, // --upgrade-module-path
 179                                   jars, // --module-path
 180                                   MAIN_MODULE) // -m
 181             .assertNormalExit(out -> {
 182                 out.shouldContain("[class,load] com.greetings.Main source: shared objects file")
 183                    .shouldMatch(".class.load. org.astro.World source:.*org.astro.jar");
 184             });
 185     }
 186 }
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File