8197531: Miscellaneous changes imported from jsr166 CVS 2018-04

Reviewed-by: martin, psandoz
This commit is contained in:
Doug Lea 2018-04-10 11:37:18 -07:00
parent a4f3a1d9eb
commit cdd36df363
27 changed files with 194 additions and 34 deletions

View file

@ -208,7 +208,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
*/
public ArrayDeque(Collection<? extends E> c) {
this(c.size());
addAll(c);
copyElements(c);
}
/**
@ -322,10 +322,14 @@ public class ArrayDeque<E> extends AbstractCollection<E>
final int s, needed;
if ((needed = (s = size()) + c.size() + 1 - elements.length) > 0)
grow(needed);
c.forEach(this::addLast);
copyElements(c);
return size() > s;
}
private void copyElements(Collection<? extends E> c) {
c.forEach(this::addLast);
}
/**
* Inserts the specified element at the front of this deque.
*

View file

@ -2883,7 +2883,7 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
STACK = l.findVarHandle(CompletableFuture.class, "stack", Completion.class);
NEXT = l.findVarHandle(Completion.class, "next", Completion.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -6383,7 +6383,7 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
ABASE = U.arrayBaseOffset(Node[].class);
int scale = U.arrayIndexScale(Node[].class);
if ((scale & (scale - 1)) != 0)
throw new Error("array index scale not a power of two");
throw new ExceptionInInitializerError("array index scale not a power of two");
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -1671,7 +1671,7 @@ public class ConcurrentLinkedDeque<E>
NEXT = l.findVarHandle(Node.class, "next", Node.class);
ITEM = l.findVarHandle(Node.class, "item", Object.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}

View file

@ -1069,7 +1069,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
ITEM = l.findVarHandle(Node.class, "item", Object.class);
NEXT = l.findVarHandle(Node.class, "next", Node.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}

View file

@ -3412,7 +3412,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
VAL = l.findVarHandle(Node.class, "val", Object.class);
RIGHT = l.findVarHandle(Index.class, "right", Index.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}

View file

@ -775,7 +775,7 @@ public abstract class CountedCompleter<T> extends ForkJoinTask<T> {
PENDING = l.findVarHandle(CountedCompleter.class, "pending", int.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}

View file

@ -641,7 +641,7 @@ public class Exchanger<V> {
MATCH = l.findVarHandle(Node.class, "match", Object.class);
AA = MethodHandles.arrayElementVarHandle(Node[].class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -1540,7 +1540,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
MethodHandles.Lookup l = MethodHandles.lookup();
STATUS = l.findVarHandle(ForkJoinTask.class, "status", int.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -526,7 +526,7 @@ public class FutureTask<V> implements RunnableFuture<V> {
RUNNER = l.findVarHandle(FutureTask.class, "runner", Thread.class);
WAITERS = l.findVarHandle(FutureTask.class, "waiters", WaitNode.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -1739,7 +1739,7 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
NEXT = l.findVarHandle(Node.class, "next", Node.class);
WAITER = l.findVarHandle(Node.class, "waiter", Thread.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -1137,7 +1137,7 @@ public class Phaser {
MethodHandles.Lookup l = MethodHandles.lookup();
STATE = l.findVarHandle(Phaser.class, "state", long.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -1014,7 +1014,7 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
"allocationSpinLock",
int.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}

View file

@ -1096,7 +1096,7 @@ public class SubmissionPublisher<T> implements Publisher<T>,
if (cap > 0) {
boolean added;
if (n >= cap && cap < maxCapacity) // resize
added = growAndoffer(item, a, t);
added = growAndOffer(item, a, t);
else if (n >= cap || unowned) // need volatile CAS
added = QA.compareAndSet(a, i, null, item);
else { // can use release mode
@ -1115,7 +1115,7 @@ public class SubmissionPublisher<T> implements Publisher<T>,
* Tries to expand buffer and add item, returning true on
* success. Currently fails only if out of memory.
*/
final boolean growAndoffer(T item, Object[] a, int t) {
final boolean growAndOffer(T item, Object[] a, int t) {
int cap = 0, newCap = 0;
Object[] newArray = null;
if (a != null && (cap = a.length) > 0 && (newCap = cap << 1) > 0) {
@ -1466,7 +1466,7 @@ public class SubmissionPublisher<T> implements Publisher<T>,
long.class);
QA = MethodHandles.arrayElementVarHandle(Object[].class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -293,7 +293,7 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
SMATCH = l.findVarHandle(SNode.class, "match", SNode.class);
SNEXT = l.findVarHandle(SNode.class, "next", SNode.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}
@ -516,7 +516,7 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
MethodHandles.Lookup l = MethodHandles.lookup();
SHEAD = l.findVarHandle(TransferStack.class, "head", SNode.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}
@ -583,7 +583,7 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
QITEM = l.findVarHandle(QNode.class, "item", Object.class);
QNEXT = l.findVarHandle(QNode.class, "next", QNode.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}
@ -830,7 +830,7 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
QCLEANME = l.findVarHandle(TransferQueue.class, "cleanMe",
QNode.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}

View file

@ -56,7 +56,7 @@ public class AtomicBoolean implements java.io.Serializable {
MethodHandles.Lookup l = MethodHandles.lookup();
VALUE = l.findVarHandle(AtomicBoolean.class, "value", int.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -199,7 +199,7 @@ public class AtomicMarkableReference<V> {
PAIR = l.findVarHandle(AtomicMarkableReference.class, "pair",
Pair.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -56,7 +56,7 @@ public class AtomicReference<V> implements java.io.Serializable {
MethodHandles.Lookup l = MethodHandles.lookup();
VALUE = l.findVarHandle(AtomicReference.class, "value", Object.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -199,7 +199,7 @@ public class AtomicStampedReference<V> {
PAIR = l.findVarHandle(AtomicStampedReference.class, "pair",
Pair.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -144,7 +144,7 @@ abstract class Striped64 extends Number {
MethodHandles.Lookup l = MethodHandles.lookup();
VALUE = l.findVarHandle(Cell.class, "value", long.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}
@ -396,13 +396,13 @@ abstract class Striped64 extends Number {
try {
return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup());
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}});
THREAD_PROBE = l.findVarHandle(Thread.class,
"threadLocalRandomProbe", int.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}

View file

@ -1830,7 +1830,7 @@ public abstract class AbstractQueuedLongSynchronizer
HEAD = l.findVarHandle(AbstractQueuedLongSynchronizer.class, "head", Node.class);
TAIL = l.findVarHandle(AbstractQueuedLongSynchronizer.class, "tail", Node.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -555,7 +555,7 @@ public abstract class AbstractQueuedSynchronizer
THREAD = l.findVarHandle(Node.class, "thread", Thread.class);
WAITSTATUS = l.findVarHandle(Node.class, "waitStatus", int.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}
@ -2308,7 +2308,7 @@ public abstract class AbstractQueuedSynchronizer
HEAD = l.findVarHandle(AbstractQueuedSynchronizer.class, "head", Node.class);
TAIL = l.findVarHandle(AbstractQueuedSynchronizer.class, "tail", Node.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
// Reduce the risk of rare disastrous classloading in first call to

View file

@ -1614,7 +1614,7 @@ public class StampedLock implements java.io.Serializable {
WNEXT = l.findVarHandle(WNode.class, "next", WNode.class);
WCOWAIT = l.findVarHandle(WNode.class, "cowait", WNode.class);
} catch (ReflectiveOperationException e) {
throw new Error(e);
throw new ExceptionInInitializerError(e);
}
}
}