test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/SharedArchiveFile

test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java

Print this page




 152                            APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 153 
 154             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 155             CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: jrt:/java.corba");
 156         }
 157     }
 158 
 159     // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules,
 160     //          the class can be loaded from -Xbootclasspath/a when the module is excluded
 161     //          using --limit-modules. Verify the behavior is the same at runtime when CDS
 162     //          is enabled.
 163     //
 164     //          The java.desktop module is excluded using --limit-modules at runtime,
 165     //          javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be
 166     //          loaded from the archive at runtime.
 167     public static void testBootAppendExcludedModuleClass() throws Exception {
 168         for (String mode : modes) {
 169             CDSOptions opts = (new CDSOptions())
 170                 .setXShareMode(mode).setUseVersion(false)
 171                 .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
 172                            "--limit-modules=java.base,jdk.internal.vm.compiler", "-cp", appJar)
 173                 .addSuffix("-Xlog:class+load=info",
 174                            APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME);
 175 
 176             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 177             CDSTestUtils.checkExec(out, opts, "[class,load] javax.sound.sampled.MyClass");
 178 
 179             // When CDS is enabled, the shared class should be loaded from the archive.
 180             if (mode.equals("on")) {
 181                 CDSTestUtils.checkExec(out, opts, "[class,load] javax.sound.sampled.MyClass source: shared objects file");
 182             }
 183         }
 184     }
 185 
 186     // Test #4: If a class on -Xbootclasspath/a has the same fully qualified
 187     //          name as a class defined in boot modules, the class is loaded
 188     //          from -Xbootclasspath/a when the boot module is excluded using
 189     //          --limit-modules. Verify the behavior is the same at runtime
 190     //          when CDS is enabled.
 191     //
 192     //          The org.omg.CORBA.Context is a boot module class. The class
 193     //          on -Xbootclasspath/a that has the same fully-qualified name
 194     //          as org.omg.CORBA.Context can be loaded at runtime when
 195     //          java.corba is excluded.
 196     public static void testBootAppendDuplicateExcludedModuleClass() throws Exception {
 197         for (String mode : modes) {
 198             CDSOptions opts = (new CDSOptions())
 199                 .setXShareMode(mode).setUseVersion(false)
 200                 .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
 201                            "--limit-modules=java.base,jdk.internal.vm.compiler", "-cp", appJar)
 202                 .addSuffix("-Xlog:class+load=info",
 203                            APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 204 
 205             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 206             CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context");
 207             if (!CDSTestUtils.isUnableToMap(out)) {
 208                 if (mode.equals("off")) {
 209                     out.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar");
 210                 } else {
 211                     CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: shared objects file");
 212                 }
 213             }
 214         }
 215     }
 216 
 217     // Test #5: If a class on -Xbootclasspath/a is not from named modules,
 218     //          the class can be loaded at runtime. Verify the behavior is
 219     //          the same at runtime when CDS is enabled.
 220     //
 221     //          The nonjdk.myPackage is not defined in named modules. The
 222     //          archived nonjdk.myPackage.MyClass from -Xbootclasspath/a
 223     //          can be loaded at runtime when CDS is enabled.
 224     public static void testBootAppendClass() throws Exception {
 225         for (String mode : modes) {
 226             CDSOptions opts = (new CDSOptions())
 227                 .setXShareMode(mode).setUseVersion(false)
 228                 .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
 229                            "--limit-modules=java.base,jdk.internal.vm.compiler", "-cp", appJar)
 230                 .addSuffix("-Xlog:class+load=info",
 231                            APP_CLASS, BOOT_APPEND_CLASS_NAME);
 232 
 233             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 234             CDSTestUtils.checkExec(out, opts, "[class,load] nonjdk.myPackage.MyClass");
 235 
 236             // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
 237             // from the shared archive.
 238             if (mode.equals("on")) {
 239                 CDSTestUtils.checkExec(out, opts,
 240                     "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
 241             }
 242         }
 243     }
 244 }


 152                            APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 153 
 154             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 155             CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: jrt:/java.corba");
 156         }
 157     }
 158 
 159     // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules,
 160     //          the class can be loaded from -Xbootclasspath/a when the module is excluded
 161     //          using --limit-modules. Verify the behavior is the same at runtime when CDS
 162     //          is enabled.
 163     //
 164     //          The java.desktop module is excluded using --limit-modules at runtime,
 165     //          javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be
 166     //          loaded from the archive at runtime.
 167     public static void testBootAppendExcludedModuleClass() throws Exception {
 168         for (String mode : modes) {
 169             CDSOptions opts = (new CDSOptions())
 170                 .setXShareMode(mode).setUseVersion(false)
 171                 .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
 172                            "--limit-modules=java.base", "-cp", appJar)
 173                 .addSuffix("-Xlog:class+load=info",
 174                            APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME);
 175 
 176             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 177             CDSTestUtils.checkExec(out, opts, "[class,load] javax.sound.sampled.MyClass");
 178 
 179             // When CDS is enabled, the shared class should be loaded from the archive.
 180             if (mode.equals("on")) {
 181                 CDSTestUtils.checkExec(out, opts, "[class,load] javax.sound.sampled.MyClass source: shared objects file");
 182             }
 183         }
 184     }
 185 
 186     // Test #4: If a class on -Xbootclasspath/a has the same fully qualified
 187     //          name as a class defined in boot modules, the class is loaded
 188     //          from -Xbootclasspath/a when the boot module is excluded using
 189     //          --limit-modules. Verify the behavior is the same at runtime
 190     //          when CDS is enabled.
 191     //
 192     //          The org.omg.CORBA.Context is a boot module class. The class
 193     //          on -Xbootclasspath/a that has the same fully-qualified name
 194     //          as org.omg.CORBA.Context can be loaded at runtime when
 195     //          java.corba is excluded.
 196     public static void testBootAppendDuplicateExcludedModuleClass() throws Exception {
 197         for (String mode : modes) {
 198             CDSOptions opts = (new CDSOptions())
 199                 .setXShareMode(mode).setUseVersion(false)
 200                 .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
 201                            "--limit-modules=java.base", "-cp", appJar)
 202                 .addSuffix("-Xlog:class+load=info",
 203                            APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 204 
 205             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 206             CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context");
 207             if (!CDSTestUtils.isUnableToMap(out)) {
 208                 if (mode.equals("off")) {
 209                     out.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar");
 210                 } else {
 211                     CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: shared objects file");
 212                 }
 213             }
 214         }
 215     }
 216 
 217     // Test #5: If a class on -Xbootclasspath/a is not from named modules,
 218     //          the class can be loaded at runtime. Verify the behavior is
 219     //          the same at runtime when CDS is enabled.
 220     //
 221     //          The nonjdk.myPackage is not defined in named modules. The
 222     //          archived nonjdk.myPackage.MyClass from -Xbootclasspath/a
 223     //          can be loaded at runtime when CDS is enabled.
 224     public static void testBootAppendClass() throws Exception {
 225         for (String mode : modes) {
 226             CDSOptions opts = (new CDSOptions())
 227                 .setXShareMode(mode).setUseVersion(false)
 228                 .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
 229                            "--limit-modules=java.base", "-cp", appJar)
 230                 .addSuffix("-Xlog:class+load=info",
 231                            APP_CLASS, BOOT_APPEND_CLASS_NAME);
 232 
 233             OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
 234             CDSTestUtils.checkExec(out, opts, "[class,load] nonjdk.myPackage.MyClass");
 235 
 236             // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
 237             // from the shared archive.
 238             if (mode.equals("on")) {
 239                 CDSTestUtils.checkExec(out, opts,
 240                     "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
 241             }
 242         }
 243     }
 244 }
test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File