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, | 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 // Max heap size for compressed oops is around 31G. UseCompressedOops is turned on 128 // by default when heap size is under 31G, but will be turned off when heap size 129 // is greater than that. This test leads to inconsistency of UseCompressedOops at dump 130 // time and runtime. 131 testDump(10, "-XX:+UseG1GC", "-Xmx1g", null, false); 132 testExec(10, "-XX:+UseG1GC", "-Xmx32g", null, true); 133 134 // CompactStrings must match between dump time and run time 135 testDump(11, "-XX:+UseG1GC", "-XX:-CompactStrings", null, false); 136 testExec(11, "-XX:+UseG1GC", "-XX:+CompactStrings", 137 COMPACT_STRING_MISMATCH, true); 138 testDump(12, "-XX:+UseG1GC", "-XX:+CompactStrings", null, false); 139 testExec(12, "-XX:+UseG1GC", "-XX:-CompactStrings", 140 COMPACT_STRING_MISMATCH, true); 141 } 142 143 static void testDump(int testCaseNr, String collectorOption, String extraOption, 144 String expectedWarning, boolean expectedToFail) throws Exception { 145 146 System.out.println("Testcase: " + testCaseNr); 147 OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list("Hello"), 148 TestCommon.concat(vmOptionsPrefix, 149 "-XX:+UseCompressedOops", 150 collectorOption, |