RFR: 8297530: java.lang.IllegalArgumentException: Negative length on strings concatenation
Claes Redestad
redestad at openjdk.org
Thu Nov 24 13:31:24 UTC 2022
When concatenating Strings, OutOfMemoryError should be thrown on all overflow conditions. This fixes a case that erroneously thro IAE on concatenations of long (`length > Integer.MAX_VALUE/2`) UTF16 strings due failing to check for overflow after shifting index left with the coder.
This was caught by a fuzzer test. Added a sanity test that fails without the patch (loosely derived from ImplicitStringConcatMany.java)
-------------
Commit messages:
- Verify the sanity test holds when -CompactStrings
- Adjust newArray to correctly throw OOME on overflow due shifting the index for UTF16 encoding
Changes: https://git.openjdk.org/jdk/pull/11354/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11354&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8297530
Stats: 143 lines in 2 files changed: 141 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/11354.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/11354/head:pull/11354
PR: https://git.openjdk.org/jdk/pull/11354
More information about the core-libs-dev
mailing list