RFR: 8356152: String.concat can throw StringIndexOutOfBoundsException [v3]
Andrey Turbanov
aturbanov at openjdk.org
Mon May 5 14:25:46 UTC 2025
On Mon, 5 May 2025 14:06:27 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> A fix to throw `OutOfMemoryError`, as done in releases ≤ 23.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>
> Added '@requires' to test.
test/jdk/java/lang/String/concat/HugeConcatTest.java line 38:
> 36: import static org.junit.Assert.assertThrows;
> 37:
> 38: public class HugeConcatTest {
The same issue is reproduced with simple `+` concatenation.
String r1 = "-".repeat(Integer.MAX_VALUE - 10);
String r2 = "ы".repeat((Integer.MAX_VALUE - 10) / 2);
System.out.println(r1 + r2);
I think it makes sense to add related test for it too.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25038#discussion_r2073551759
More information about the core-libs-dev
mailing list