Skip to content

Commit 1ca008f

Browse files
author
David Holmes
committed
8360255: runtime/jni/checked/TestLargeUTF8Length.java fails with -XX:-CompactStrings
Reviewed-by: shade, kbarrett
1 parent cf75f1f commit 1ca008f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/hotspot/jtreg/runtime/jni/checked/TestLargeUTF8Length.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ public class TestLargeUTF8Length {
4444
static native void checkUTF8Length(String s, long utf8Length);
4545

4646
static void test() {
47-
int length = Integer.MAX_VALUE/2 + 1;
48-
char character = (char)0XD1; // N with tilde
49-
long utf8Length = 2L * length;
47+
// We want a string whose UTF-8 length is > Integer.MAX_VALUE, but
48+
// whose "natural" length is < Integer.MAX_VALUE/2 so it can be
49+
// created regardless of whether compact-strings are enabled or not.
50+
// So we use a character that encodes as 3-bytes in UTF-8.
51+
// U+08A0 : e0 a2 a0 : ARABIC LETTER BEH WITH SMALL V BELOW
52+
char character = '\u08A0';
53+
int length = Integer.MAX_VALUE/2 - 1;
54+
long utf8Length = 3L * length;
5055
char[] chrs = new char[length];
5156
Arrays.fill(chrs, character);
5257
String s = new String(chrs);

0 commit comments

Comments
 (0)