RFR JDK-8011200 (was 7143928) : (coll) Optimize for Empty ArrayList and HashMap

Alan Bateman Alan.Bateman at oracle.com
Thu Apr 11 13:03:43 UTC 2013

On 10/04/2013 19:12, Mike Duigou wrote:
> On Apr 9 2013, at 19:56 , Martin Buchholz wrote:
>> Mike, thanks.
>> I don't see anything wrong in this version, although the ongoing complexification and special-case-ification (with attendant risk of bugs) of ArrayList and HashMap, the two most didactically important classes, continue to bother me.  This change continues to feel marginal.
> It was surprising to find just how many ArrayList and HashMap instances were empty and/or never used. Unfortunately it's harder to globally fix applications than it is to and special case code to ArrayList and HashMap.
Right and I wonder if the performance folks could share some of the data 
that they have gathered on this.

In any case, I think this patch is looking good now, assuming this is 
the near-to-final version:


One remaining point that I'm a bit uneasy about is ArrayList.writeObject 
writing out the size rather than the array length. It is specified to be 
the array backing the ArrayList. It's now ignored by readObject (which 
is good) but reconstituting on an older/other JDK release will/may 
reconstitute to the trimmed size.


More information about the core-libs-dev mailing list