< prev index next >

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

Print this page

104         runWithJarPath();
105     }
106 
107     private static void tty(String... args) {
108         for (String s : args) {
109             System.out.print(s + " ");
110         }
111         System.out.print("\n");
112     }
113 
114     public static void runWithModulePath(String... extraRuntimeArgs) throws Exception {
115         // compile the modules and create the modular jar files
116         buildTestModule();
117         String appClasses[] = {MAIN_CLASS, TEST_CLASS};
118         // create an archive with the classes in the modules built in the
119         // previous step
120         OutputAnalyzer output = TestCommon.createArchive(
121                                         null, appClasses,
122                                         "--module-path",
123                                         libsDir.toString(),
124                                         "-m", MAIN_MODULE);

125         TestCommon.checkDump(output);
126 
127         // following 1 - 4 test with CDS off
128         tty("1. run with CDS off");
129         TestCommon.execOff( "-p", libsDir.toString(),
130                             "-m", MAIN_MODULE)
131             .shouldHaveExitValue(0)
132             .shouldNotContain(OPTIMIZE_ENABLED)
133             .shouldContain(CLASS_FOUND_MESSAGE);
134         tty("2. run with CDS off, without module path");
135         TestCommon.execOff("-cp",
136                            mainJar.toString(),
137                            MAIN_CLASS)
138             .shouldHaveExitValue(0)
139             .shouldContain(CLASS_NOT_FOUND_MESSAGE);
140         tty("3. run with CDS off, but with full jars in path");
141         TestCommon.execOff( "-cp", mainJar.toString() + PATH_SEPARATOR + testJar.toString(),
142                             MAIN_CLASS)
143             .shouldHaveExitValue(0)
144             .shouldNotContain(OPTIMIZE_ENABLED)

227         tty("11. run with CDS on, --module-path, with -Xbootclasspath/a:.");
228         TestCommon.run("-Xlog:cds",
229                        "-Xbootclasspath/a:.",
230                        "--module-path", libsDir.toString(),
231                        MAIN_CLASS)
232             .assertAbnormalExit(out -> {
233                 out.shouldNotContain(CLASS_FOUND_MESSAGE)
234                    .shouldContain(OPTIMIZE_DISABLED)           // mapping info
235                    .shouldContain("shared class paths mismatch");
236             });
237     }
238 
239     public static void runWithJarPath(String... extraRuntimeArgs) throws Exception {
240         // compile the modules and create the modular jar files
241         buildTestModule();
242         String appClasses[] = {MAIN_CLASS, TEST_CLASS};
243         // create an archive with the classes in the modules built in the
244         // previous step
245         OutputAnalyzer output = TestCommon.createArchive(
246                                     testJar.toString() + PATH_SEPARATOR + mainJar.toString(),
247                                     appClasses);
248         TestCommon.checkDump(output);
249 
250         // tests 1 - 4 test with CDS off are same as with module archive.
251         tty("tests 1 - 4 test with CDS off are same as with module archive, skipped");
252 
253         // Following 5 - 9 test with CDS on
254         tty("5. run with CDS on, with module path");
255         String prefix[] = {"-Djava.class.path=", "-Xlog:cds"};
256         TestCommon.runWithModules(prefix,
257                                   null,               // --upgrade-module-path
258                                   libsDir.toString(), // --module-path
259                                   MAIN_MODULE)        // -m
260             .assertAbnormalExit(out -> {
261                 out.shouldContain(MAP_FAILED)
262                    .shouldNotContain(OPTIMIZE_ENABLED)
263                    .shouldNotContain(CLASS_FOUND_MESSAGE);
264             });
265         tty("6. run with CDS on, with module paths set correctly");
266         TestCommon.run("-Xlog:cds",
267                        "-p", libsDir.toString(),

104         runWithJarPath();
105     }
106 
107     private static void tty(String... args) {
108         for (String s : args) {
109             System.out.print(s + " ");
110         }
111         System.out.print("\n");
112     }
113 
114     public static void runWithModulePath(String... extraRuntimeArgs) throws Exception {
115         // compile the modules and create the modular jar files
116         buildTestModule();
117         String appClasses[] = {MAIN_CLASS, TEST_CLASS};
118         // create an archive with the classes in the modules built in the
119         // previous step
120         OutputAnalyzer output = TestCommon.createArchive(
121                                         null, appClasses,
122                                         "--module-path",
123                                         libsDir.toString(),
124                                         "-m", MAIN_MODULE,
125                                         "-XX:-PreloadSharedClasses");
126         TestCommon.checkDump(output);
127 
128         // following 1 - 4 test with CDS off
129         tty("1. run with CDS off");
130         TestCommon.execOff( "-p", libsDir.toString(),
131                             "-m", MAIN_MODULE)
132             .shouldHaveExitValue(0)
133             .shouldNotContain(OPTIMIZE_ENABLED)
134             .shouldContain(CLASS_FOUND_MESSAGE);
135         tty("2. run with CDS off, without module path");
136         TestCommon.execOff("-cp",
137                            mainJar.toString(),
138                            MAIN_CLASS)
139             .shouldHaveExitValue(0)
140             .shouldContain(CLASS_NOT_FOUND_MESSAGE);
141         tty("3. run with CDS off, but with full jars in path");
142         TestCommon.execOff( "-cp", mainJar.toString() + PATH_SEPARATOR + testJar.toString(),
143                             MAIN_CLASS)
144             .shouldHaveExitValue(0)
145             .shouldNotContain(OPTIMIZE_ENABLED)

228         tty("11. run with CDS on, --module-path, with -Xbootclasspath/a:.");
229         TestCommon.run("-Xlog:cds",
230                        "-Xbootclasspath/a:.",
231                        "--module-path", libsDir.toString(),
232                        MAIN_CLASS)
233             .assertAbnormalExit(out -> {
234                 out.shouldNotContain(CLASS_FOUND_MESSAGE)
235                    .shouldContain(OPTIMIZE_DISABLED)           // mapping info
236                    .shouldContain("shared class paths mismatch");
237             });
238     }
239 
240     public static void runWithJarPath(String... extraRuntimeArgs) throws Exception {
241         // compile the modules and create the modular jar files
242         buildTestModule();
243         String appClasses[] = {MAIN_CLASS, TEST_CLASS};
244         // create an archive with the classes in the modules built in the
245         // previous step
246         OutputAnalyzer output = TestCommon.createArchive(
247                                     testJar.toString() + PATH_SEPARATOR + mainJar.toString(),
248                                     appClasses, "-XX:-PreloadSharedClasses");
249         TestCommon.checkDump(output);
250 
251         // tests 1 - 4 test with CDS off are same as with module archive.
252         tty("tests 1 - 4 test with CDS off are same as with module archive, skipped");
253 
254         // Following 5 - 9 test with CDS on
255         tty("5. run with CDS on, with module path");
256         String prefix[] = {"-Djava.class.path=", "-Xlog:cds"};
257         TestCommon.runWithModules(prefix,
258                                   null,               // --upgrade-module-path
259                                   libsDir.toString(), // --module-path
260                                   MAIN_MODULE)        // -m
261             .assertAbnormalExit(out -> {
262                 out.shouldContain(MAP_FAILED)
263                    .shouldNotContain(OPTIMIZE_ENABLED)
264                    .shouldNotContain(CLASS_FOUND_MESSAGE);
265             });
266         tty("6. run with CDS on, with module paths set correctly");
267         TestCommon.run("-Xlog:cds",
268                        "-p", libsDir.toString(),
< prev index next >