Integrated: 8360255: runtime/jni/checked/TestLargeUTF8Length.java fails with -XX:-CompactStrings
David Holmes
dholmes at openjdk.org
Thu Jun 26 01:05:36 UTC 2025
On Wed, 25 Jun 2025 07:54:16 GMT, David Holmes <dholmes 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
This pull request has now been integrated.
Changeset: 1ca008fd
Author: David Holmes <dholmes at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/1ca008fd02496dc33e2707c102560cae1690fba5
Stats: 8 lines in 1 file changed: 5 ins; 0 del; 3 mod
8360255: runtime/jni/checked/TestLargeUTF8Length.java fails with -XX:-CompactStrings
Reviewed-by: shade, kbarrett
-------------
PR: https://git.openjdk.org/jdk/pull/25970
More information about the hotspot-runtime-dev
mailing list