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

Print this page




 101                                     "--module-path", MODS_DIR.toString(),
 102                                     "--add-modules", TEST_MODULE2,
 103                                     "--add-exports", "org.astro/org.astro=ALL-UNNAMED");
 104         Asserts.assertTrue(compiled, "test package did not compile");
 105 
 106         appJar2 = moduleDir2.resolve(PKG_NAME + ".jar");
 107         classes = MODS_DIR.resolve(PKG_NAME).toString();
 108         JarBuilder.createModularJar(appJar2.toString(), classes, null);
 109     }
 110 
 111     public static void main(String... args) throws Exception {
 112         // compile the modules and create the modular jar files
 113         buildTestModule();
 114         String appClasses[] = {MAIN_CLASS, APP_CLASS};
 115         // create an archive with the class in the org.astro module built in the
 116         // previous step and the main class from the modular jar in the -cp
 117         // note: the main class is in the modular jar in the -cp which requires
 118         // the module in the --module-path
 119         OutputAnalyzer output = TestCommon.createArchive(
 120                                         appJar.toString(), appClasses,
 121                                         "-Xlog:class+load=trace",
 122                                         "--module-path", moduleDir.toString(),
 123                                         "--add-modules", TEST_MODULE2, MAIN_CLASS);
 124         TestCommon.checkDump(output);
 125 
 126         // run it using the archive
 127         // both the main class and the class from the org.astro module should
 128         // be loaded from the archive
 129         TestCommon.run("-Xlog:class+load=trace",
 130                               "-cp", appJar.toString(),
 131                               "--module-path", moduleDir.toString(),
 132                               "--add-modules", TEST_MODULE2, MAIN_CLASS)
 133             .assertNormalExit(
 134                 "[class,load] org.astro.World source: shared objects file",
 135                 "[class,load] com.greetings.Main source: shared objects file");
 136 
 137         String appClasses2[] = {UNNAMED_MAIN, APP_CLASS};
 138         // create an archive with the main class from a non-modular jar in the
 139         // -cp and the class from the org.astro module
 140         // note: the org.astro package needs to be exported to "ALL-UNNAMED"
 141         // module since the jar in the -cp is a non-modular jar and thus it is
 142         // unnmaed.
 143         output = TestCommon.createArchive(
 144                                         appJar2.toString(), appClasses2,
 145                                         "-Xlog:class+load=trace",
 146                                         "--module-path", moduleDir.toString(),
 147                                         "--add-modules", TEST_MODULE2,
 148                                         "--add-exports", "org.astro/org.astro=ALL-UNNAMED",
 149                                         UNNAMED_MAIN);
 150         TestCommon.checkDump(output);
 151 
 152         // both the main class and the class from the org.astro module should
 153         // be loaded from the archive
 154         TestCommon.run("-Xlog:class+load=trace",
 155                        "-cp", appJar2.toString(),
 156                        "--module-path", moduleDir.toString(),
 157                        "--add-modules", TEST_MODULE2,
 158                        "--add-exports", "org.astro/org.astro=ALL-UNNAMED",
 159                        UNNAMED_MAIN)
 160             .assertNormalExit(
 161                 "[class,load] org.astro.World source: shared objects file",
 162                 "[class,load] com.nomodule.Main source: shared objects file");
 163     }
 164 }


 101                                     "--module-path", MODS_DIR.toString(),
 102                                     "--add-modules", TEST_MODULE2,
 103                                     "--add-exports", "org.astro/org.astro=ALL-UNNAMED");
 104         Asserts.assertTrue(compiled, "test package did not compile");
 105 
 106         appJar2 = moduleDir2.resolve(PKG_NAME + ".jar");
 107         classes = MODS_DIR.resolve(PKG_NAME).toString();
 108         JarBuilder.createModularJar(appJar2.toString(), classes, null);
 109     }
 110 
 111     public static void main(String... args) throws Exception {
 112         // compile the modules and create the modular jar files
 113         buildTestModule();
 114         String appClasses[] = {MAIN_CLASS, APP_CLASS};
 115         // create an archive with the class in the org.astro module built in the
 116         // previous step and the main class from the modular jar in the -cp
 117         // note: the main class is in the modular jar in the -cp which requires
 118         // the module in the --module-path
 119         OutputAnalyzer output = TestCommon.createArchive(
 120                                         appJar.toString(), appClasses,

 121                                         "--module-path", moduleDir.toString(),
 122                                         "--add-modules", TEST_MODULE2, MAIN_CLASS);
 123         TestCommon.checkDump(output);
 124 
 125         // run it using the archive
 126         // both the main class and the class from the org.astro module should
 127         // be loaded from the archive
 128         TestCommon.run("-Xlog:class+load=trace",
 129                               "-cp", appJar.toString(),
 130                               "--module-path", moduleDir.toString(),
 131                               "--add-modules", TEST_MODULE2, MAIN_CLASS)
 132             .assertNormalExit(
 133                 "[class,load] org.astro.World source: shared objects file",
 134                 "[class,load] com.greetings.Main source: shared objects file");
 135 
 136         String appClasses2[] = {UNNAMED_MAIN, APP_CLASS};
 137         // create an archive with the main class from a non-modular jar in the
 138         // -cp and the class from the org.astro module
 139         // note: the org.astro package needs to be exported to "ALL-UNNAMED"
 140         // module since the jar in the -cp is a non-modular jar and thus it is
 141         // unnmaed.
 142         output = TestCommon.createArchive(
 143                                         appJar2.toString(), appClasses2,

 144                                         "--module-path", moduleDir.toString(),
 145                                         "--add-modules", TEST_MODULE2,
 146                                         "--add-exports", "org.astro/org.astro=ALL-UNNAMED",
 147                                         UNNAMED_MAIN);
 148         TestCommon.checkDump(output);
 149 
 150         // both the main class and the class from the org.astro module should
 151         // be loaded from the archive
 152         TestCommon.run("-Xlog:class+load=trace",
 153                        "-cp", appJar2.toString(),
 154                        "--module-path", moduleDir.toString(),
 155                        "--add-modules", TEST_MODULE2,
 156                        "--add-exports", "org.astro/org.astro=ALL-UNNAMED",
 157                        UNNAMED_MAIN)
 158             .assertNormalExit(
 159                 "[class,load] org.astro.World source: shared objects file",
 160                 "[class,load] com.nomodule.Main source: shared objects file");
 161     }
 162 }
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File