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

Martin Buchholz martinrb at google.com
Thu Apr 4 17:32:57 UTC 2013


On Tue, Apr 2, 2013 at 3:50 PM, Mike Duigou <mike.duigou at oracle.com> wrote:

- T I will file a spec change request for the addition of ", a power of 2" to the @serialData tag for this existing but previously unstated requirement.

Hi Mike,

I think changing the serialization spec is a mistake. There are a bunch of collection classes that use power-of-two backing arrays, but it's clearly the intent of the authors that this be an implementation detail. As often happens, implementation details get accidentally exposed ("leaked") in a serial form. Here we see that the size of the backing array is embedded in the serial form. There is an incompatibility between the OpenJDK HashMap implementation and other implementations that don't use power-of-two backing arrays (which may not exist) but the right fix is to make the OpenJDK implementation more resilient to the input serial form. Treat the backing array size as merely a hint. If it's not a power of two, make it so! That is, remove the "previously unstated requirement".



More information about the core-libs-dev mailing list