RFR: JDK-8146568 NegativeArraySizeException in ArrayList.grow(int)

Remi Forax forax at univ-mlv.fr
Tue Jan 26 12:28:21 UTC 2016


Hi Martin,
sorry for jumping on this conversation lately,
please don't be seduced by the dark side,

I understand that the code is 1 byte bigger, but i think that the following code
  final int s = this.size;
  Object[] elementData = this.elementData;
  if (s == elementData.length) {
      elementData = grow();
  }

is more readable than
  final int s;
  Object[] elementData;
  if ((s = size) == (elementData = this.elementData).length)
      elementData = grow();

cheers,
Rémi

----- Mail original -----
> De: "Martin Buchholz" <martinrb at google.com>
> À: "Stuart Marks" <stuart.marks at oracle.com>
> Cc: "core-libs-dev" <core-libs-dev at openjdk.java.net>
> Envoyé: Mardi 26 Janvier 2016 01:49:41
> Objet: Re: RFR: JDK-8146568 NegativeArraySizeException in ArrayList.grow(int)
> 
> I already regret touching crufty old Vector, but it had the same bug
> to fix, and more surprisingly the same sort of performance improvement
> from doing the obvious port.  So ... Stuart, please review also
> 
> http://cr.openjdk.java.net/~martin/webrevs/openjdk9/Vector-grow/
> https://bugs.openjdk.java.net/browse/JDK-8148174
> 
> 
> On Fri, Jan 22, 2016 at 2:30 PM, Stuart Marks <stuart.marks at oracle.com>
> wrote:
> >
> >
> > On 1/22/16 12:02 PM, Martin Buchholz wrote:
> >>
> >> I went "by the book" as you suggested and now throw
> >> InvalidObjectException when size < 0.
> >> (But I've been saying for a decade: if we're serious about
> >> Serialization, it needs to be someone's full time job)
> >
> >
> > "Admiral, if we go by the book, years could turn into decades."
> >
> > Thanks for the update; this looks great to me.
> >
> > s'marks
> 



More information about the core-libs-dev mailing list