RFR: 8149330: Capacity of StringBuilder should not get close to Integer.MAX_VALUE unless necessary
ivan.gerasimov at oracle.com
Tue Mar 1 17:33:54 UTC 2016
I added another regtest to perform some basic sanity checks wrt
In this test I we only operate on relatively small sizes.
A situation when capacity grows large is checked in a separate test,
which is ignored by default.
Do you think this fix is good to go?
Comments, suggestions are very welcome.
On 23.02.2016 20:29, Martin Buchholz wrote:
> On Tue, Feb 23, 2016 at 7:20 AM, Ivan Gerasimov
> <ivan.gerasimov at oracle.com> wrote:
>> While writing this, I just noticed that I actually made a mistake when did
>> newCapacity < 0 check.
>> This wouldn't catch the overflow when the oldCapacity happens to be
>> Integer.MAX_VALUE (which is not possible with the current hotspot, but may
>> become an issue one day).
> Well done!
> One interesting way that capacity may end up being Integer.MAX_VALUE
> is if we switch to char for storage. Then in LATIN1 mode you could
> store Integer.MAX_VALUE elements even without help from hotspot!
More information about the core-libs-dev