RFR: 8350811: [JMH] test foreign.StrLenTest failed with StringIndexOutOfBoundsException for size=451 [v2]
Vladimir Ivanov
vaivanov at openjdk.org
Thu Mar 6 00:43:05 UTC 2025
On Wed, 5 Mar 2025 23:29:42 GMT, Volodymyr Paprotski <vpaprotski at openjdk.org> wrote:
>> Vladimir Ivanov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> JDK-8350811 [JMH] test foreign.StrLenTest failed with StringIndexOutOfBoundsException for size=451
>
> test/micro/org/openjdk/bench/java/lang/foreign/StrLenTest.java line 149:
>
>> 147: while (lorem.length() < size) {
>> 148: lorem += lorem;
>> 149: }
>
> This is matter of taste, but I would prefer StringBuilder instead:
>
> StringBuilder builder = new StringBuilder(lorem.length()+size);
> for (int l = 0; l<size; l+=lorem.length()) {
> builder.append(lorem);
> }
> return builder.substring(0, size);
The initial version looks more readable for me.
While it initialization part no need to tune performance here and simple version should be OK.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23873#discussion_r1982384108
More information about the core-libs-dev
mailing list