Am 05.03.2010 10:04, schrieb Martin Buchholz:
Hi Kevin,
As you've noticed, creating objects within a factor of two of
their natural limits is a good way to expose lurking bugs.
I'm the one responsible for the algorithm in ArrayList.
I'm a bit embarrassed, looking at that code today.
We could set the array size to Integer.MAX_VALUE,
but then you might hit an independent buglet in hotspot
that you cannot allocate an array with Integer.MAX_VALUE
elements, but Integer.MAX_VALUE - 5 (or so) works.
I think, using a max size of Integer.MAX_VALUE - x looks awful, in
particular if it's badly commented in the sources.
I suggest to introduce something like
System.MAX_COLLECTION_SIZE/CAPACITY or .maxCollectionSize/Capacity().
-Ulf