RFR: jsr166 jdk9 integration wave 12 (original) (raw)
Doug Lea dl at cs.oswego.edu
Fri Nov 18 13:02:48 UTC 2016
- Previous message: RFR: jsr166 jdk9 integration wave 12
- Next message: RFR: jsr166 jdk9 integration wave 12
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/18/2016 02:28 AM, Remi Forax wrote:
Martin, for ArrayDeque, when you start to have methods like @SuppressWarnings("unchecked") static final 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.
We always use Object[] in cases where anyfication isn't possible (without further code rework) because we rely on null as a distinct value. Elsewhere we do use E[].
-Doug
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" <martinrb at google.com> À: "core-libs-dev" <core-libs-dev at openjdk.java.net>, "Doug Lea" <dl at cs.oswego.edu>, "Stuart Marks" <stuart.marks at oracle.com>, "Paul Sandoz" <paul.sandoz at 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.
- Previous message: RFR: jsr166 jdk9 integration wave 12
- Next message: RFR: jsr166 jdk9 integration wave 12
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]