Martin, for ArrayDeque, when you start to have methods like @SuppressWarnings("unchecked") static final <E> E elementAt(Object[] es, int i) { return (E) es[i]; }
I think it's a better idea to type the field elements as a E[] instead of Object[]. Historically, using Object(] instead of E[] was preferred because it's a kind of 'more true' at runtime, but it will be less true with anyfied generics and as we can see if it leads to introduce method like elementAt, using E[] will make the code more readable. so the constructors should be: @SuppressWarnings("unchecked") public ArrayDeque() { elements = (E[])new Object[16]; } (same transformation for ArrayDeque(int)). And you can remove all the casts to E and the corresponnding SuppressWarnings and remove the method elementAt. Rémi ----- Mail original ----- > De: "Martin Buchholz" <marti...@google.com> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net>, "Doug Lea" > <d...@cs.oswego.edu>, "Stuart Marks" > <stuart.ma...@oracle.com>, "Paul Sandoz" <paul.san...@oracle.com> > Envoyé: Mardi 18 Octobre 2016 03:34:34 > Objet: RFR: jsr166 jdk9 integration wave 12 > Most of this is for Stuart - very collection-y. > > http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ > > This includes a rewrite of ArrayDeque to bring it to parity with ArrayList > (except for List features). > The patch includes public methods ensureCapacity, trimToSize, replaceAll as > in ArrayList, but we can defer making them public to a later change (or a > later release), since new public methods are always controversial. But I'd > really like to get the performance/scalability changes in for jdk 9. > > It also includes a redo of ArrayList#removeIf to make it more efficient and > consistent with behavior of other implementations, including ArrayDeque. > > The patches are a little tangled because they step on each other's toes. > File CollectionTest is in "miscellaneous", but it tests both the ArrayDeque > and ArrayList changes.