< prev index next >

test/runtime/SharedArchiveFile/BootAppendTests.java

Print this page




 143     //          should not be loaded at runtime when CDS is enabled.
 144     //          The one from the boot modules should be loaded instead.
 145     public static void testBootAppendDuplicateModuleClass() throws Exception {
 146         for (String mode : modes) {
 147             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 148                 "-XX:+UnlockDiagnosticVMOptions",
 149                 "-XX:SharedArchiveFile=./BootAppendTests.jsa",
 150                 "-XX:+TraceClassLoading",
 151                 "-cp", appJar,
 152                 "-Xbootclasspath/a:" + bootAppendJar,
 153                 "-Xshare:" + mode,
 154                 APP_CLASS,
 155                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 156             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 157             output.shouldContain("[class,load] org.omg.CORBA.Context source: jrt:/java.corba");
 158         }
 159     }
 160 
 161     // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules,
 162     //          the class can be loaded from -Xbootclasspath/a when the module is excluded
 163     //          using -limitmods. Verify the behavior is the same at runtime when CDS is
 164     //          enabled.
 165     //
 166     //          The java.desktop module is excluded using -limitmods at runtime,
 167     //          javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be
 168     //          loaded from the archive at runtime.
 169     public static void testBootAppendExcludedModuleClass() throws Exception {
 170         for (String mode : modes) {
 171             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 172                 "-XX:+UnlockDiagnosticVMOptions",
 173                 "-XX:SharedArchiveFile=./BootAppendTests.jsa",
 174                 "-XX:+TraceClassLoading",
 175                 "-cp", appJar,
 176                 "-Xbootclasspath/a:" + bootAppendJar,
 177                 "-limitmods", "java.base",
 178                 "-Xshare:" + mode,
 179                 APP_CLASS,
 180                 BOOT_APPEND_MODULE_CLASS_NAME);
 181             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 182             output.shouldContain("[class,load] javax.sound.sampled.MyClass");
 183 
 184             // When CDS is enabled, the shared class should be loaded from the archive.
 185             if (mode.equals("on")) {
 186                 output.shouldContain("[class,load] javax.sound.sampled.MyClass source: shared objects file");
 187             }
 188         }
 189     }
 190 
 191     // Test #4: If a class on -Xbootclasspath/a has the same fully qualified
 192     //          name as a class defined in boot modules, the class is loaded
 193     //          from -Xbootclasspath/a when the boot module is excluded using
 194     //          -limitmods. Verify the behavior is the same at runtime when CDS is
 195     //          enabled.
 196     //
 197     //          The org.omg.CORBA.Context is a boot module class. The class
 198     //          on -Xbootclasspath/a that has the same fully-qualified name
 199     //          as org.omg.CORBA.Context can be loaded at runtime when
 200     //          java.corba is excluded.
 201     public static void testBootAppendDuplicateExcludedModuleClass() throws Exception {
 202         for (String mode : modes) {
 203             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 204                 "-XX:+UnlockDiagnosticVMOptions",
 205                 "-XX:SharedArchiveFile=./BootAppendTests.jsa",
 206                 "-XX:+TraceClassLoading",
 207                 "-cp", appJar,
 208                 "-Xbootclasspath/a:" + bootAppendJar,
 209                 "-limitmods", "java.base",
 210                 "-Xshare:" + mode,
 211                 APP_CLASS,
 212                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 213             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 214             output.shouldContain("[class,load] org.omg.CORBA.Context");
 215             output.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar");
 216         }
 217     }
 218 
 219     // Test #5: If a class on -Xbootclasspath/a is not from named modules,
 220     //          the class can be loaded at runtime. Verify the behavior is
 221     //          the same at runtime when CDS is enabled.
 222     //
 223     //          The nonjdk.myPackage is not defined in named modules. The
 224     //          archived nonjdk.myPackage.MyClass from -Xbootclasspath/a
 225     //          can be loaded at runtime when CDS is enabled.
 226     public static void testBootAppendClass() throws Exception {
 227         for (String mode : modes) {
 228             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 229                 "-XX:+UnlockDiagnosticVMOptions",


 143     //          should not be loaded at runtime when CDS is enabled.
 144     //          The one from the boot modules should be loaded instead.
 145     public static void testBootAppendDuplicateModuleClass() throws Exception {
 146         for (String mode : modes) {
 147             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 148                 "-XX:+UnlockDiagnosticVMOptions",
 149                 "-XX:SharedArchiveFile=./BootAppendTests.jsa",
 150                 "-XX:+TraceClassLoading",
 151                 "-cp", appJar,
 152                 "-Xbootclasspath/a:" + bootAppendJar,
 153                 "-Xshare:" + mode,
 154                 APP_CLASS,
 155                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 156             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 157             output.shouldContain("[class,load] org.omg.CORBA.Context source: jrt:/java.corba");
 158         }
 159     }
 160 
 161     // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules,
 162     //          the class can be loaded from -Xbootclasspath/a when the module is excluded
 163     //          using --limit-modules. Verify the behavior is the same at runtime when CDS
 164     //          is enabled.
 165     //
 166     //          The java.desktop module is excluded using --limit-modules at runtime,
 167     //          javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be
 168     //          loaded from the archive at runtime.
 169     public static void testBootAppendExcludedModuleClass() throws Exception {
 170         for (String mode : modes) {
 171             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 172                 "-XX:+UnlockDiagnosticVMOptions",
 173                 "-XX:SharedArchiveFile=./BootAppendTests.jsa",
 174                 "-XX:+TraceClassLoading",
 175                 "-cp", appJar,
 176                 "-Xbootclasspath/a:" + bootAppendJar,
 177                 "--limit-modules=java.base",
 178                 "-Xshare:" + mode,
 179                 APP_CLASS,
 180                 BOOT_APPEND_MODULE_CLASS_NAME);
 181             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 182             output.shouldContain("[class,load] javax.sound.sampled.MyClass");
 183 
 184             // When CDS is enabled, the shared class should be loaded from the archive.
 185             if (mode.equals("on")) {
 186                 output.shouldContain("[class,load] javax.sound.sampled.MyClass source: shared objects file");
 187             }
 188         }
 189     }
 190 
 191     // Test #4: If a class on -Xbootclasspath/a has the same fully qualified
 192     //          name as a class defined in boot modules, the class is loaded
 193     //          from -Xbootclasspath/a when the boot module is excluded using
 194     //          --limit-modules. Verify the behavior is the same at runtime
 195     //          when CDS is enabled.
 196     //
 197     //          The org.omg.CORBA.Context is a boot module class. The class
 198     //          on -Xbootclasspath/a that has the same fully-qualified name
 199     //          as org.omg.CORBA.Context can be loaded at runtime when
 200     //          java.corba is excluded.
 201     public static void testBootAppendDuplicateExcludedModuleClass() throws Exception {
 202         for (String mode : modes) {
 203             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 204                 "-XX:+UnlockDiagnosticVMOptions",
 205                 "-XX:SharedArchiveFile=./BootAppendTests.jsa",
 206                 "-XX:+TraceClassLoading",
 207                 "-cp", appJar,
 208                 "-Xbootclasspath/a:" + bootAppendJar,
 209                 "--limit-modules=java.base",
 210                 "-Xshare:" + mode,
 211                 APP_CLASS,
 212                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
 213             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 214             output.shouldContain("[class,load] org.omg.CORBA.Context");
 215             output.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar");
 216         }
 217     }
 218 
 219     // Test #5: If a class on -Xbootclasspath/a is not from named modules,
 220     //          the class can be loaded at runtime. Verify the behavior is
 221     //          the same at runtime when CDS is enabled.
 222     //
 223     //          The nonjdk.myPackage is not defined in named modules. The
 224     //          archived nonjdk.myPackage.MyClass from -Xbootclasspath/a
 225     //          can be loaded at runtime when CDS is enabled.
 226     public static void testBootAppendClass() throws Exception {
 227         for (String mode : modes) {
 228             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 229                 "-XX:+UnlockDiagnosticVMOptions",
< prev index next >