[PATCH] Use StringJoiner where appropriate in java.base

Peter Levart peter.levart at gmail.com
Fri Jun 21 08:44:50 UTC 2019



On 6/21/19 9:41 AM, Andrew Haley wrote:
> On 6/20/19 9:31 PM, Peter Levart wrote:
>
>> I would also add overflow checks when computing the length of
>> resulting byte[]. First I would pre-check the length of passed in
>> int[] array (it must be less than Integer.MAX_VALUE / 3), then
>> checking for negative size after each addition of element length,
>> throwing OOME if overflow happens.
> OutOfMemoryException? Are you sure? The system isn't out of memory or
> any other resource, it's just that the arguments are too large. Also,
> it might be cleaner to use addExact().
>

StringBuilder throws OutOfMemoryError when appending over its maximum 
capacity, so I thought this would keep that behavior.

Regards, Peter



More information about the core-libs-dev mailing list