RFR: jsr166 jdk9 integration wave 12 (original) (raw)

Martin Buchholz martinrb at google.com
Fri Nov 18 03:17:33 UTC 2016


Here's an update that adds some explanations, addresses some of Paul's comments, and improves handling of capacities near 2**31.

Coincidentally, today I got access to a machine with enough memory to run testHugeCapacity without dying, so that test gets fixed. Previous iterations tried to get rid of the spare slot, and there may be some other lingering vestige of that, as with this test.

Index: src/main/java/util/ArrayDeque.java

RCS file: /export/home/jsr166/jsr166/jsr166/src/main/java/util/ArrayDeque.java,v retrieving revision 1.113 diff -u -r1.113 ArrayDeque.java --- src/main/java/util/ArrayDeque.java 13 Nov 2016 02:10:09 -0000 1.113 +++ src/main/java/util/ArrayDeque.java 18 Nov 2016 03:09:50 -0000 @@ -68,13 +68,15 @@ * * Because in a circular array, elements are in general stored in * two disjoint such slices, we help the VM by writing unusual

@@ -88,7 +90,8 @@

 /**
  * The index at which the next element would be added to the tail

@@ -187,7 +190,10 @@ * @param numElements lower bound on initial capacity of the deque */ public ArrayDeque(int numElements) {

Integer.MAX_VALUE :

@@ -201,7 +207,7 @@ * @throws NullPointerException if the specified collection is null */ public ArrayDeque(Collection<? extends E> c) {

@@ -224,19 +230,21 @@ }

 /**

@@ -862,9 +870,9 @@ if ((t = fence) < 0) t = getFence(); if (t == (i = cursor)) return false;

@@ -1232,6 +1240,8 @@

 /** debugging */
 void checkInvariants() {

Index: src/main/java/util/concurrent/ArrayBlockingQueue.java

RCS file: /export/home/jsr166/jsr166/jsr166/src/main/java/util/concurrent/ArrayBlockingQueue.java,v retrieving revision 1.137 diff -u -r1.137 ArrayBlockingQueue.java --- src/main/java/util/concurrent/ArrayBlockingQueue.java 13 Nov 2016 02:10:09 -0000 1.137 +++ src/main/java/util/concurrent/ArrayBlockingQueue.java 18 Nov 2016 03:09:50 -0000 @@ -58,6 +58,11 @@ public class ArrayBlockingQueue extends AbstractQueue implements BlockingQueue, java.io.Serializable {

@@ -1555,6 +1560,10 @@ // meta-assertions // assert lock.isHeldByCurrentThread(); try { + // Unlike ArrayDeque, we have a count field but no spare slot. + // We prefer ArrayDeque's strategy, but our field layout is + // baked into the serial form, and so is annoying to change. + // putIndex == takeIndex must be disambiguated by checking count. int capacity = items.length; // assert capacity > 0; // assert takeIndex >= 0 && takeIndex < capacity; Index: src/test/tck/ArrayDeque8Test.java

RCS file: /export/home/jsr166/jsr166/jsr166/src/test/tck/ArrayDeque8Test.java,v retrieving revision 1.1 diff -u -r1.1 ArrayDeque8Test.java --- src/test/tck/ArrayDeque8Test.java 25 Oct 2016 01:32:55 -0000 1.1 +++ src/test/tck/ArrayDeque8Test.java 18 Nov 2016 03:09:51 -0000 @@ -51,43 +51,42 @@

 /**
  * Handle capacities near Integer.MAX_VALUE.

-Djsr166.testImplementationDetails=true -Djsr166.expensiveTests=true -Djsr166.tckTestClass=ArrayDequeTest -Djsr166.methodFilter=testHuge tck

-Djsr166.tckTestClass=ArrayDeque8Test -Djsr166.methodFilter=testHugeCapacity tck */



More information about the core-libs-dev mailing list