Skip to content

Commit dada6dd

Browse files
Roger Riggspull[bot]
authored andcommitted
8322018: Test java/lang/String/CompactString/MaxSizeUTF16String.java fails with -Xcomp
Reviewed-by: jpai
1 parent 8f9028b commit dada6dd

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

test/jdk/java/lang/String/CompactString/MaxSizeUTF16String.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@
3030
* @test
3131
* @bug 8077559 8321180
3232
* @summary Tests Compact String for maximum size strings
33-
* @requires os.maxMemory >= 7g & vm.bits == 64
34-
* @run junit/othervm -XX:+CompactStrings -Xmx7g MaxSizeUTF16String
35-
* @run junit/othervm -XX:-CompactStrings -Xmx7g MaxSizeUTF16String
33+
* @requires os.maxMemory >= 8g & vm.bits == 64
34+
* @requires vm.flagless
35+
* @run junit/othervm -XX:+CompactStrings -Xmx8g MaxSizeUTF16String
36+
* @run junit/othervm -XX:-CompactStrings -Xmx8g MaxSizeUTF16String
37+
* @run junit/othervm -Xcomp -Xmx8g MaxSizeUTF16String
3638
*/
3739

3840
public class MaxSizeUTF16String {
3941

4042
private final static int MAX_UTF16_STRING_LENGTH = Integer.MAX_VALUE / 2;
4143

4244
private final static String EXPECTED_OOME_MESSAGE = "UTF16 String size is";
45+
private final static String EXPECTED_VM_LIMIT_MESSAGE = "Requested array size exceeds VM limit";
46+
private final static String UNEXPECTED_JAVA_HEAP_SPACE = "Java heap space";
4347

4448
// Create a large UTF-8 byte array with a single non-latin1 character
4549
private static byte[] generateUTF8Data(int byteSize) {
@@ -74,7 +78,12 @@ public void testMaxUTF8() {
7478
fail("Expected OutOfMemoryError with message prefix: " + EXPECTED_OOME_MESSAGE);
7579
}
7680
} catch (OutOfMemoryError ex) {
77-
if (!ex.getMessage().startsWith(EXPECTED_OOME_MESSAGE)) {
81+
if (ex.getMessage().equals(UNEXPECTED_JAVA_HEAP_SPACE)) {
82+
// Insufficient heap size
83+
throw ex;
84+
}
85+
if (!ex.getMessage().startsWith(EXPECTED_OOME_MESSAGE) &&
86+
!ex.getMessage().startsWith(EXPECTED_VM_LIMIT_MESSAGE)) {
7887
fail("Failed: Not the OutOfMemoryError expected", ex);
7988
}
8089
}
@@ -98,7 +107,12 @@ public void testMaxCharArray() {
98107
fail("Expected OutOfMemoryError with message prefix: " + EXPECTED_OOME_MESSAGE);
99108
}
100109
} catch (OutOfMemoryError ex) {
101-
if (!ex.getMessage().startsWith(EXPECTED_OOME_MESSAGE)) {
110+
if (ex.getMessage().equals(UNEXPECTED_JAVA_HEAP_SPACE)) {
111+
// Insufficient heap size
112+
throw ex;
113+
}
114+
if (!ex.getMessage().startsWith(EXPECTED_OOME_MESSAGE) &&
115+
!ex.getMessage().startsWith(EXPECTED_VM_LIMIT_MESSAGE)) {
102116
throw new RuntimeException("Wrong exception message: " + ex.getMessage(), ex);
103117
}
104118
}

0 commit comments

Comments
 (0)