RFR: 8360255: runtime/jni/checked/TestLargeUTF8Length.java fails with -XX:-CompactStrings

David Holmes dholmes at openjdk.org
Thu Jun 26 01:05:34 UTC 2025


On Thu, 26 Jun 2025 00:10:05 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> 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
>
> Looks good.

Thanks for the review @kimbarrett !

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25970#issuecomment-3006655458


More information about the hotspot-runtime-dev mailing list