Skip to content

Commit cdd36df

Browse files
author
Doug Lea
committed
8197531: Miscellaneous changes imported from jsr166 CVS 2018-04
Reviewed-by: martin, psandoz
1 parent a4f3a1d commit cdd36df

27 files changed

+194
-34
lines changed

src/java.base/share/classes/java/util/ArrayDeque.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public ArrayDeque(int numElements) {
208208
*/
209209
public ArrayDeque(Collection<? extends E> c) {
210210
this(c.size());
211-
addAll(c);
211+
copyElements(c);
212212
}
213213

214214
/**
@@ -322,10 +322,14 @@ public boolean addAll(Collection<? extends E> c) {
322322
final int s, needed;
323323
if ((needed = (s = size()) + c.size() + 1 - elements.length) > 0)
324324
grow(needed);
325-
c.forEach(this::addLast);
325+
copyElements(c);
326326
return size() > s;
327327
}
328328

329+
private void copyElements(Collection<? extends E> c) {
330+
c.forEach(this::addLast);
331+
}
332+
329333
/**
330334
* Inserts the specified element at the front of this deque.
331335
*

src/java.base/share/classes/java/util/concurrent/CompletableFuture.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2883,7 +2883,7 @@ static final class MinimalStage<T> extends CompletableFuture<T> {
28832883
STACK = l.findVarHandle(CompletableFuture.class, "stack", Completion.class);
28842884
NEXT = l.findVarHandle(Completion.class, "next", Completion.class);
28852885
} catch (ReflectiveOperationException e) {
2886-
throw new Error(e);
2886+
throw new ExceptionInInitializerError(e);
28872887
}
28882888

28892889
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6383,7 +6383,7 @@ public final void compute() {
63836383
ABASE = U.arrayBaseOffset(Node[].class);
63846384
int scale = U.arrayIndexScale(Node[].class);
63856385
if ((scale & (scale - 1)) != 0)
6386-
throw new Error("array index scale not a power of two");
6386+
throw new ExceptionInInitializerError("array index scale not a power of two");
63876387
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
63886388

63896389
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ public void forEach(Consumer<? super E> action) {
16711671
NEXT = l.findVarHandle(Node.class, "next", Node.class);
16721672
ITEM = l.findVarHandle(Node.class, "item", Object.class);
16731673
} catch (ReflectiveOperationException e) {
1674-
throw new Error(e);
1674+
throw new ExceptionInInitializerError(e);
16751675
}
16761676
}
16771677
}

src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ public void forEach(Consumer<? super E> action) {
10691069
ITEM = l.findVarHandle(Node.class, "item", Object.class);
10701070
NEXT = l.findVarHandle(Node.class, "next", Node.class);
10711071
} catch (ReflectiveOperationException e) {
1072-
throw new Error(e);
1072+
throw new ExceptionInInitializerError(e);
10731073
}
10741074
}
10751075
}

src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3412,7 +3412,7 @@ final EntrySpliterator<K,V> entrySpliterator() {
34123412
VAL = l.findVarHandle(Node.class, "val", Object.class);
34133413
RIGHT = l.findVarHandle(Index.class, "right", Index.class);
34143414
} catch (ReflectiveOperationException e) {
3415-
throw new Error(e);
3415+
throw new ExceptionInInitializerError(e);
34163416
}
34173417
}
34183418
}

src/java.base/share/classes/java/util/concurrent/CountedCompleter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ protected void setRawResult(T t) { }
775775
PENDING = l.findVarHandle(CountedCompleter.class, "pending", int.class);
776776

777777
} catch (ReflectiveOperationException e) {
778-
throw new Error(e);
778+
throw new ExceptionInInitializerError(e);
779779
}
780780
}
781781
}

src/java.base/share/classes/java/util/concurrent/Exchanger.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ public V exchange(V x, long timeout, TimeUnit unit)
641641
MATCH = l.findVarHandle(Node.class, "match", Object.class);
642642
AA = MethodHandles.arrayElementVarHandle(Node[].class);
643643
} catch (ReflectiveOperationException e) {
644-
throw new Error(e);
644+
throw new ExceptionInInitializerError(e);
645645
}
646646
}
647647

src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ private void readObject(java.io.ObjectInputStream s)
15401540
MethodHandles.Lookup l = MethodHandles.lookup();
15411541
STATUS = l.findVarHandle(ForkJoinTask.class, "status", int.class);
15421542
} catch (ReflectiveOperationException e) {
1543-
throw new Error(e);
1543+
throw new ExceptionInInitializerError(e);
15441544
}
15451545
}
15461546

src/java.base/share/classes/java/util/concurrent/FutureTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public String toString() {
526526
RUNNER = l.findVarHandle(FutureTask.class, "runner", Thread.class);
527527
WAITERS = l.findVarHandle(FutureTask.class, "waiters", WaitNode.class);
528528
} catch (ReflectiveOperationException e) {
529-
throw new Error(e);
529+
throw new ExceptionInInitializerError(e);
530530
}
531531

532532
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ public void forEach(Consumer<? super E> action) {
17391739
NEXT = l.findVarHandle(Node.class, "next", Node.class);
17401740
WAITER = l.findVarHandle(Node.class, "waiter", Thread.class);
17411741
} catch (ReflectiveOperationException e) {
1742-
throw new Error(e);
1742+
throw new ExceptionInInitializerError(e);
17431743
}
17441744

17451745
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/Phaser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ public boolean block() {
11371137
MethodHandles.Lookup l = MethodHandles.lookup();
11381138
STATE = l.findVarHandle(Phaser.class, "state", long.class);
11391139
} catch (ReflectiveOperationException e) {
1140-
throw new Error(e);
1140+
throw new ExceptionInInitializerError(e);
11411141
}
11421142

11431143
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ public Spliterator<E> spliterator() {
10141014
"allocationSpinLock",
10151015
int.class);
10161016
} catch (ReflectiveOperationException e) {
1017-
throw new Error(e);
1017+
throw new ExceptionInInitializerError(e);
10181018
}
10191019
}
10201020
}

src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ final int offer(T item, boolean unowned) {
10961096
if (cap > 0) {
10971097
boolean added;
10981098
if (n >= cap && cap < maxCapacity) // resize
1099-
added = growAndoffer(item, a, t);
1099+
added = growAndOffer(item, a, t);
11001100
else if (n >= cap || unowned) // need volatile CAS
11011101
added = QA.compareAndSet(a, i, null, item);
11021102
else { // can use release mode
@@ -1115,7 +1115,7 @@ else if (n >= cap || unowned) // need volatile CAS
11151115
* Tries to expand buffer and add item, returning true on
11161116
* success. Currently fails only if out of memory.
11171117
*/
1118-
final boolean growAndoffer(T item, Object[] a, int t) {
1118+
final boolean growAndOffer(T item, Object[] a, int t) {
11191119
int cap = 0, newCap = 0;
11201120
Object[] newArray = null;
11211121
if (a != null && (cap = a.length) > 0 && (newCap = cap << 1) > 0) {
@@ -1466,7 +1466,7 @@ else if (timed)
14661466
long.class);
14671467
QA = MethodHandles.arrayElementVarHandle(Object[].class);
14681468
} catch (ReflectiveOperationException e) {
1469-
throw new Error(e);
1469+
throw new ExceptionInInitializerError(e);
14701470
}
14711471

14721472
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ boolean isCancelled() {
293293
SMATCH = l.findVarHandle(SNode.class, "match", SNode.class);
294294
SNEXT = l.findVarHandle(SNode.class, "next", SNode.class);
295295
} catch (ReflectiveOperationException e) {
296-
throw new Error(e);
296+
throw new ExceptionInInitializerError(e);
297297
}
298298
}
299299
}
@@ -516,7 +516,7 @@ void clean(SNode s) {
516516
MethodHandles.Lookup l = MethodHandles.lookup();
517517
SHEAD = l.findVarHandle(TransferStack.class, "head", SNode.class);
518518
} catch (ReflectiveOperationException e) {
519-
throw new Error(e);
519+
throw new ExceptionInInitializerError(e);
520520
}
521521
}
522522
}
@@ -583,7 +583,7 @@ boolean isOffList() {
583583
QITEM = l.findVarHandle(QNode.class, "item", Object.class);
584584
QNEXT = l.findVarHandle(QNode.class, "next", QNode.class);
585585
} catch (ReflectiveOperationException e) {
586-
throw new Error(e);
586+
throw new ExceptionInInitializerError(e);
587587
}
588588
}
589589
}
@@ -830,7 +830,7 @@ void clean(QNode pred, QNode s) {
830830
QCLEANME = l.findVarHandle(TransferQueue.class, "cleanMe",
831831
QNode.class);
832832
} catch (ReflectiveOperationException e) {
833-
throw new Error(e);
833+
throw new ExceptionInInitializerError(e);
834834
}
835835
}
836836
}

src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class AtomicBoolean implements java.io.Serializable {
5656
MethodHandles.Lookup l = MethodHandles.lookup();
5757
VALUE = l.findVarHandle(AtomicBoolean.class, "value", int.class);
5858
} catch (ReflectiveOperationException e) {
59-
throw new Error(e);
59+
throw new ExceptionInInitializerError(e);
6060
}
6161
}
6262

src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public boolean attemptMark(V expectedReference, boolean newMark) {
199199
PAIR = l.findVarHandle(AtomicMarkableReference.class, "pair",
200200
Pair.class);
201201
} catch (ReflectiveOperationException e) {
202-
throw new Error(e);
202+
throw new ExceptionInInitializerError(e);
203203
}
204204
}
205205

src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class AtomicReference<V> implements java.io.Serializable {
5656
MethodHandles.Lookup l = MethodHandles.lookup();
5757
VALUE = l.findVarHandle(AtomicReference.class, "value", Object.class);
5858
} catch (ReflectiveOperationException e) {
59-
throw new Error(e);
59+
throw new ExceptionInInitializerError(e);
6060
}
6161
}
6262

src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public boolean attemptStamp(V expectedReference, int newStamp) {
199199
PAIR = l.findVarHandle(AtomicStampedReference.class, "pair",
200200
Pair.class);
201201
} catch (ReflectiveOperationException e) {
202-
throw new Error(e);
202+
throw new ExceptionInInitializerError(e);
203203
}
204204
}
205205

src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ final long getAndSet(long val) {
144144
MethodHandles.Lookup l = MethodHandles.lookup();
145145
VALUE = l.findVarHandle(Cell.class, "value", long.class);
146146
} catch (ReflectiveOperationException e) {
147-
throw new Error(e);
147+
throw new ExceptionInInitializerError(e);
148148
}
149149
}
150150
}
@@ -396,13 +396,13 @@ public MethodHandles.Lookup run() {
396396
try {
397397
return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup());
398398
} catch (ReflectiveOperationException e) {
399-
throw new Error(e);
399+
throw new ExceptionInInitializerError(e);
400400
}
401401
}});
402402
THREAD_PROBE = l.findVarHandle(Thread.class,
403403
"threadLocalRandomProbe", int.class);
404404
} catch (ReflectiveOperationException e) {
405-
throw new Error(e);
405+
throw new ExceptionInInitializerError(e);
406406
}
407407
}
408408

src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ protected final Collection<Thread> getWaitingThreads() {
18301830
HEAD = l.findVarHandle(AbstractQueuedLongSynchronizer.class, "head", Node.class);
18311831
TAIL = l.findVarHandle(AbstractQueuedLongSynchronizer.class, "tail", Node.class);
18321832
} catch (ReflectiveOperationException e) {
1833-
throw new Error(e);
1833+
throw new ExceptionInInitializerError(e);
18341834
}
18351835

18361836
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ final void setPrevRelaxed(Node p) {
555555
THREAD = l.findVarHandle(Node.class, "thread", Thread.class);
556556
WAITSTATUS = l.findVarHandle(Node.class, "waitStatus", int.class);
557557
} catch (ReflectiveOperationException e) {
558-
throw new Error(e);
558+
throw new ExceptionInInitializerError(e);
559559
}
560560
}
561561
}
@@ -2308,7 +2308,7 @@ protected final Collection<Thread> getWaitingThreads() {
23082308
HEAD = l.findVarHandle(AbstractQueuedSynchronizer.class, "head", Node.class);
23092309
TAIL = l.findVarHandle(AbstractQueuedSynchronizer.class, "tail", Node.class);
23102310
} catch (ReflectiveOperationException e) {
2311-
throw new Error(e);
2311+
throw new ExceptionInInitializerError(e);
23122312
}
23132313

23142314
// Reduce the risk of rare disastrous classloading in first call to

src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ private long cancelWaiter(WNode node, WNode group, boolean interrupted) {
16141614
WNEXT = l.findVarHandle(WNode.class, "next", WNode.class);
16151615
WCOWAIT = l.findVarHandle(WNode.class, "cowait", WNode.class);
16161616
} catch (ReflectiveOperationException e) {
1617-
throw new Error(e);
1617+
throw new ExceptionInInitializerError(e);
16181618
}
16191619
}
16201620
}

0 commit comments

Comments
 (0)