92 String[] noargs = {}; 93 SharedStringsUtils.run(Integer.parseInt(args[0]), 3, noargs, IncompatibleOptions::test); 94 // Add a new @test block if you get an assert ----^ about this number. See 95 // SharedStringsUtils.java for details. 96 } 97 98 public static void test(String[] args_ignored) throws Exception { 99 vmOptionsPrefix = SharedStringsUtils.getChildVMOptionsPrefix(); 100 appJar = JarBuilder.build("IncompatibleOptions", "HelloString"); 101 102 // Uncompressed OOPs 103 testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", null, false); 104 if (GC.Z.isSupported()) { 105 testDump(1, "-XX:+UseZGC", "-XX:-UseCompressedOops", null, false); 106 } 107 108 // incompatible GCs 109 testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false); 110 testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false); 111 112 // ======= archive with compressed oops, run w/o 113 testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false); 114 testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops", 115 COMPRESSED_OOPS_NOT_CONSISTENT, true); 116 117 // NOTE: No warning is displayed, by design 118 // Still run, to ensure no crash or exception 119 testExec(6, "-XX:+UseParallelGC", "", "", false); 120 testExec(7, "-XX:+UseSerialGC", "", "", false); 121 122 // Test various oops encodings, by varying ObjectAlignmentInBytes and heap sizes 123 testDump(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=8", null, false); 124 testExec(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=16", 125 OBJ_ALIGNMENT_MISMATCH, true); 126 127 // See JDK-8081416 - Oops encoding mismatch with shared strings 128 // produces unclear or incorrect warning 129 // Correct the test case once the above is fixed 130 // @ignore JDK-8081416 - for tracking purposes 131 // for now, run test as is until the proper behavior is determined 132 testDump(10, "-XX:+UseG1GC", "-Xmx1g", null, false); 133 testExec(10, "-XX:+UseG1GC", "-Xmx32g", null, true); 134 135 // CompactStrings must match between dump time and run time 136 testDump(11, "-XX:+UseG1GC", "-XX:-CompactStrings", null, false); 137 testExec(11, "-XX:+UseG1GC", "-XX:+CompactStrings", 138 COMPACT_STRING_MISMATCH, true); 139 testDump(12, "-XX:+UseG1GC", "-XX:+CompactStrings", null, false); 140 testExec(12, "-XX:+UseG1GC", "-XX:-CompactStrings", 141 COMPACT_STRING_MISMATCH, true); 142 } 143 144 static void testDump(int testCaseNr, String collectorOption, String extraOption, 145 String expectedWarning, boolean expectedToFail) throws Exception { 146 147 System.out.println("Testcase: " + testCaseNr); 148 OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"), 149 TestCommon.concat(vmOptionsPrefix, 150 "-XX:+UseCompressedOops", 151 collectorOption, 152 "-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile("SharedStringsBasic.txt"), 153 "-Xlog:cds,cds+hashtables", 154 extraOption)); 155 156 if (expectedWarning != null) { 157 output.shouldContain(expectedWarning); 158 } 159 160 if (expectedToFail) { 161 Asserts.assertNE(output.getExitValue(), 0, | 92 String[] noargs = {}; 93 SharedStringsUtils.run(Integer.parseInt(args[0]), 3, noargs, IncompatibleOptions::test); 94 // Add a new @test block if you get an assert ----^ about this number. See 95 // SharedStringsUtils.java for details. 96 } 97 98 public static void test(String[] args_ignored) throws Exception { 99 vmOptionsPrefix = SharedStringsUtils.getChildVMOptionsPrefix(); 100 appJar = JarBuilder.build("IncompatibleOptions", "HelloString"); 101 102 // Uncompressed OOPs 103 testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", null, false); 104 if (GC.Z.isSupported()) { 105 testDump(1, "-XX:+UseZGC", "-XX:-UseCompressedOops", null, false); 106 } 107 108 // incompatible GCs 109 testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false); 110 testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false); 111 112 // Explicitly archive with compressed oops, run without. 113 testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false); 114 testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops", 115 COMPRESSED_OOPS_NOT_CONSISTENT, true); 116 117 // NOTE: No warning is displayed, by design 118 // Still run, to ensure no crash or exception 119 testExec(6, "-XX:+UseParallelGC", "", "", false); 120 testExec(7, "-XX:+UseSerialGC", "", "", false); 121 122 // Test various oops encodings, by varying ObjectAlignmentInBytes and heap sizes 123 testDump(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=8", null, false); 124 testExec(9, "-XX:+UseG1GC", "-XX:ObjectAlignmentInBytes=16", 125 OBJ_ALIGNMENT_MISMATCH, true); 126 127 // Implicitly archive with compressed oops, run without. 128 // Max heap size for compressed oops is around 31G. 129 // UseCompressedOops is turned on by default when heap 130 // size is under 31G, but will be turned off when heap 131 // size is greater than that. 132 testDump(10, "-XX:+UseG1GC", "-Xmx1g", null, false); 133 testExec(10, "-XX:+UseG1GC", "-Xmx32g", null, true); 134 135 // CompactStrings must match between dump time and run time 136 testDump(11, "-XX:+UseG1GC", "-XX:-CompactStrings", null, false); 137 testExec(11, "-XX:+UseG1GC", "-XX:+CompactStrings", 138 COMPACT_STRING_MISMATCH, true); 139 testDump(12, "-XX:+UseG1GC", "-XX:+CompactStrings", null, false); 140 testExec(12, "-XX:+UseG1GC", "-XX:-CompactStrings", 141 COMPACT_STRING_MISMATCH, true); 142 // Explicitly archive without compressed oops and run with. 143 testDump(13, "-XX:+UseG1GC", "-XX:-UseCompressedOops", null, false); 144 testExec(13, "-XX:+UseG1GC", "-XX:-UseCompressedOops", null, false); 145 // Implicitly archive without compressed oops and run with. 146 testDump(14, "-XX:+UseG1GC", "-Xmx32G", null, false); 147 testExec(14, "-XX:+UseG1GC", "-Xmx32G", null, false); 148 } 149 150 static void testDump(int testCaseNr, String collectorOption, String extraOption, 151 String expectedWarning, boolean expectedToFail) throws Exception { 152 153 System.out.println("Testcase: " + testCaseNr); 154 OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"), 155 TestCommon.concat(vmOptionsPrefix, 156 "-XX:+UseCompressedOops", 157 collectorOption, 158 "-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile("SharedStringsBasic.txt"), 159 "-Xlog:cds,cds+hashtables", 160 extraOption)); 161 162 if (expectedWarning != null) { 163 output.shouldContain(expectedWarning); 164 } 165 166 if (expectedToFail) { 167 Asserts.assertNE(output.getExitValue(), 0, |