RFR: 8360255: runtime/jni/checked/TestLargeUTF8Length.java fails with -XX:-CompactStrings
David Holmes
dholmes at openjdk.org
Wed Jun 25 08:00:06 UTC 2025
The test creates a `String` with `Integer.MAX_VALUE/2 + 1` characters, where the character encodes as two bytes in UTF-8. That way we test when the UTF-8 length is greater than `Integer.MAX_VALUE`. However, when compact strings are disabled the maximum length of a `String`, in characters, is `Integer.MAX_VALUE/2` so the test throws a (synthetic) OOME.
The fix I chose was to change the test so that we create a slightly shorter `String` (that will always fit regardless of the compact-strings setting) but to fill it with a character that encodes to three bytes in UTF-8. Hence we still test that the UTF-8 length exceeds `Integer.MAX_LENGTH`.
Tested on Windows x64, Linux x64 and Aarch64, macOS x64 and Aarch64; on release and fastdebug builds.
Thanks
-------------
Commit messages:
- 8360255: runtime/jni/checked/TestLargeUTF8Length.java fails with -XX:-CompactStrings
Changes: https://git.openjdk.org/jdk/pull/25970/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25970&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8360255
Stats: 8 lines in 1 file changed: 5 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/25970.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25970/head:pull/25970
PR: https://git.openjdk.org/jdk/pull/25970
More information about the hotspot-runtime-dev
mailing list