test/hotspot/jtreg/runtime/appcds/sharedStrings/IncompatibleOptions.java
changeset 51527 dda0f219dafa
parent 51491 187c84a5efe1
child 51616 b071f4fff1f1
equal deleted inserted replaced
51526:42d36db61500 51527:dda0f219dafa
    27  * @summary Test options that are incompatible with use of shared strings
    27  * @summary Test options that are incompatible with use of shared strings
    28  *          Also test mismatch in oops encoding between dump time and run time
    28  *          Also test mismatch in oops encoding between dump time and run time
    29  * @requires vm.cds.archived.java.heap
    29  * @requires vm.cds.archived.java.heap
    30  * @requires (vm.gc=="null")
    30  * @requires (vm.gc=="null")
    31  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
    31  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
    32  * @modules java.base/jdk.internal.misc
    32  * @modules jdk.jartool/sun.tools.jar
    33  * @modules java.management
       
    34  *          jdk.jartool/sun.tools.jar
       
    35  * @build sun.hotspot.WhiteBox
    33  * @build sun.hotspot.WhiteBox
    36  * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
    34  * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
    37  * @build HelloString
    35  * @build HelloString
    38  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
    36  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
    39  * @run main/othervm -XX:+UseStringDeduplication -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
       
    40  * @run main/othervm -XX:-CompactStrings -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
       
    41  */
    37  */
    42 
    38 
    43 import jdk.test.lib.Asserts;
    39 import jdk.test.lib.Asserts;
    44 import jdk.test.lib.Platform;
    40 import jdk.test.lib.Platform;
    45 import jdk.test.lib.process.OutputAnalyzer;
    41 import jdk.test.lib.process.OutputAnalyzer;
    57         "The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of";
    53         "The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of";
    58     static final String COMPACT_STRING_MISMATCH =
    54     static final String COMPACT_STRING_MISMATCH =
    59         "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting";
    55         "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting";
    60 
    56 
    61     static String appJar;
    57     static String appJar;
       
    58     static String[] globalVmOptions;
    62 
    59 
    63     public static void main(String[] args) throws Exception {
    60     public static void main(String[] args) throws Exception {
       
    61         globalVmOptions = args; // specified by "@run main" in IncompatibleOptions_*.java
    64         appJar = JarBuilder.build("IncompatibleOptions", "HelloString");
    62         appJar = JarBuilder.build("IncompatibleOptions", "HelloString");
    65 
    63 
    66         // Uncompressed OOPs
    64         // Uncompressed OOPs
    67         testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);
    65         testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);
    68         if (Platform.isLinux() && Platform.isX64()) {
    66         if (Platform.isLinux() && Platform.isX64()) {
   114     static void testDump(int testCaseNr, String collectorOption, String extraOption,
   112     static void testDump(int testCaseNr, String collectorOption, String extraOption,
   115         String expectedWarning, boolean expectedToFail) throws Exception {
   113         String expectedWarning, boolean expectedToFail) throws Exception {
   116 
   114 
   117         System.out.println("Testcase: " + testCaseNr);
   115         System.out.println("Testcase: " + testCaseNr);
   118         OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"),
   116         OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"),
   119             "-XX:+UseCompressedOops",
   117             TestCommon.concat(globalVmOptions,
   120             collectorOption,
   118                 "-XX:+UseCompressedOops",
   121             "-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile("SharedStringsBasic.txt"),
   119                 collectorOption,
   122             "-Xlog:cds,cds+hashtables",
   120                 "-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile("SharedStringsBasic.txt"),
   123             extraOption);
   121                 "-Xlog:cds,cds+hashtables",
       
   122                 extraOption));
   124 
   123 
   125         if (expectedWarning != null)
   124         if (expectedWarning != null) {
   126             output.shouldContain(expectedWarning);
   125             output.shouldContain(expectedWarning);
       
   126         }
   127 
   127 
   128         if (expectedToFail) {
   128         if (expectedToFail) {
   129             Asserts.assertNE(output.getExitValue(), 0,
   129             Asserts.assertNE(output.getExitValue(), 0,
   130             "JVM is expected to fail, but did not");
   130             "JVM is expected to fail, but did not");
   131         }
   131         }
   138         System.out.println("Testcase: " + testCaseNr);
   138         System.out.println("Testcase: " + testCaseNr);
   139 
   139 
   140         // needed, otherwise system considers empty extra option as a
   140         // needed, otherwise system considers empty extra option as a
   141         // main class param, and fails with "Could not find or load main class"
   141         // main class param, and fails with "Could not find or load main class"
   142         if (!extraOption.isEmpty()) {
   142         if (!extraOption.isEmpty()) {
   143             output = TestCommon.exec(appJar, "-XX:+UseCompressedOops",
   143             output = TestCommon.exec(appJar,
   144                 collectorOption, "-Xlog:cds", extraOption, "HelloString");
   144                 TestCommon.concat(globalVmOptions,
       
   145                     "-XX:+UseCompressedOops",
       
   146                     collectorOption, "-Xlog:cds", extraOption, "HelloString"));
   145         } else {
   147         } else {
   146             output = TestCommon.exec(appJar, "-XX:+UseCompressedOops",
   148             output = TestCommon.exec(appJar,
   147                 collectorOption, "-Xlog:cds", "HelloString");
   149                 TestCommon.concat(globalVmOptions,
       
   150                     "-XX:+UseCompressedOops",
       
   151                     collectorOption, "-Xlog:cds", "HelloString"));
   148         }
   152         }
   149 
   153 
   150         if (expectedWarning != null)
   154         if (expectedWarning != null) {
   151             output.shouldMatch(expectedWarning);
   155             output.shouldMatch(expectedWarning);
       
   156         }
   152 
   157 
   153         if (expectedToFail)
   158         if (expectedToFail) {
   154             Asserts.assertNE(output.getExitValue(), 0);
   159             Asserts.assertNE(output.getExitValue(), 0);
   155         else
   160         } else {
   156             SharedStringsUtils.checkExec(output);
   161             SharedStringsUtils.checkExec(output);
       
   162         }
   157     }
   163     }
   158 }
   164 }