[PATCH] Use StringJoiner where appropriate in java.base

Andrew Haley aph at redhat.com
Fri Jun 21 07:41:56 UTC 2019


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

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the core-libs-dev mailing list