RFR: 8350811: [JMH] test foreign.StrLenTest failed with StringIndexOutOfBoundsException for size=451 [v2]

Volodymyr Paprotski vpaprotski at openjdk.org
Thu Mar 6 00:46:59 UTC 2025


On Thu, 6 Mar 2025 00:39:59 GMT, Vladimir Ivanov <vaivanov at openjdk.org> wrote:

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

Sounds good

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23873#discussion_r1982387796


More information about the core-libs-dev mailing list