Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/StackStreamFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public int characteristics() {
}

@Override
public void forEachRemaining(Consumer<? super StackFrame> action) {
public void forEachRemaining(Consumer<? super StackFrame>! action) {
checkState(OPEN);
for (int n = 0; n < maxDepth; n++) {
StackFrame frame = nextStackFrame();
Expand All @@ -585,7 +585,7 @@ public void forEachRemaining(Consumer<? super StackFrame> action) {
}

@Override
public boolean tryAdvance(Consumer<? super StackFrame> action) {
public boolean tryAdvance(Consumer<? super StackFrame>! action) {
checkState(OPEN);

int index = frameBuffer.getIndex();
Expand Down
12 changes: 4 additions & 8 deletions src/java.base/share/classes/java/lang/StringLatin1.java
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ private String next() {
}

@Override
public boolean tryAdvance(Consumer<? super String> action) {
public boolean tryAdvance(Consumer<? super String>! action) {
if (action == null) {
throw new NullPointerException("tryAdvance action missing");
}
Expand All @@ -784,7 +784,7 @@ public boolean tryAdvance(Consumer<? super String> action) {
}

@Override
public void forEachRemaining(Consumer<? super String> action) {
public void forEachRemaining(Consumer<? super String>! action) {
if (action == null) {
throw new NullPointerException("forEachRemaining action missing");
}
Expand Down Expand Up @@ -896,20 +896,16 @@ public OfInt trySplit() {
}

@Override
public void forEachRemaining(IntConsumer action) {
public void forEachRemaining(IntConsumer! action) {
byte[] a; int i, hi; // hoist accesses and checks from loop
if (action == null)
throw new NullPointerException();
if ((a = array).length >= (hi = fence) &&
(i = index) >= 0 && i < (index = hi)) {
do { action.accept(a[i] & 0xff); } while (++i < hi);
}
}

@Override
public boolean tryAdvance(IntConsumer action) {
if (action == null)
throw new NullPointerException();
public boolean tryAdvance(IntConsumer! action) {
if (index >= 0 && index < fence) {
action.accept(array[index++] & 0xff);
return true;
Expand Down
26 changes: 6 additions & 20 deletions src/java.base/share/classes/java/lang/StringUTF16.java
Original file line number Diff line number Diff line change
Expand Up @@ -1341,10 +1341,7 @@ private String next() {
}

@Override
public boolean tryAdvance(Consumer<? super String> action) {
if (action == null) {
throw new NullPointerException("tryAdvance action missing");
}
public boolean tryAdvance(Consumer<? super String>! action) {
if (index != fence) {
action.accept(next());
return true;
Expand All @@ -1353,10 +1350,7 @@ public boolean tryAdvance(Consumer<? super String> action) {
}

@Override
public void forEachRemaining(Consumer<? super String> action) {
if (action == null) {
throw new NullPointerException("forEachRemaining action missing");
}
public void forEachRemaining(Consumer<? super String>! action) {
while (index != fence) {
action.accept(next());
}
Expand Down Expand Up @@ -1433,10 +1427,8 @@ public OfInt trySplit() {
}

@Override
public void forEachRemaining(IntConsumer action) {
public void forEachRemaining(IntConsumer! action) {
byte[] a; int i, hi; // hoist accesses and checks from loop
if (action == null)
throw new NullPointerException();
if (((a = array).length >> 1) >= (hi = fence) &&
(i = index) >= 0 && i < (index = hi)) {
do {
Expand All @@ -1446,9 +1438,7 @@ public void forEachRemaining(IntConsumer action) {
}

@Override
public boolean tryAdvance(IntConsumer action) {
if (action == null)
throw new NullPointerException();
public boolean tryAdvance(IntConsumer! action) {
int i = index;
if (i >= 0 && i < fence) {
action.accept(charAt(array, i));
Expand Down Expand Up @@ -1504,10 +1494,8 @@ public OfInt trySplit() {
}

@Override
public void forEachRemaining(IntConsumer action) {
public void forEachRemaining(IntConsumer! action) {
byte[] a; int i, hi; // hoist accesses and checks from loop
if (action == null)
throw new NullPointerException();
if (((a = array).length >> 1) >= (hi = fence) &&
(i = index) >= 0 && i < (index = hi)) {
do {
Expand All @@ -1517,9 +1505,7 @@ public void forEachRemaining(IntConsumer action) {
}

@Override
public boolean tryAdvance(IntConsumer action) {
if (action == null)
throw new NullPointerException();
public boolean tryAdvance(IntConsumer! action) {
if (index >= 0 && index < fence) {
index = advance(array, index, fence, action);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public OfInt trySplit() {
}

@Override
public void forEachRemaining(IntConsumer action) {
if (action == null)
throw new NullPointerException();
public void forEachRemaining(IntConsumer! action) {
CharBuffer cb = buffer;
int i = index;
int hi = limit;
Expand All @@ -74,9 +72,7 @@ public void forEachRemaining(IntConsumer action) {
}

@Override
public boolean tryAdvance(IntConsumer action) {
if (action == null)
throw new NullPointerException();
public boolean tryAdvance(IntConsumer! action) {
if (index >= 0 && index < limit) {
action.accept(buffer.getUnchecked(index++));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private FileChannelLinesSpliterator(FileChannel fc, Charset cs, int index,
}

@Override
public boolean tryAdvance(Consumer<? super String> action) {
public boolean tryAdvance(Consumer<? super String>! action) {
String line = readLine();
if (line != null) {
action.accept(line);
Expand All @@ -124,7 +124,7 @@ public boolean tryAdvance(Consumer<? super String> action) {
}

@Override
public void forEachRemaining(Consumer<? super String> action) {
public void forEachRemaining(Consumer<? super String>! action) {
String line;
while ((line = readLine()) != null) {
action.accept(line);
Expand Down
7 changes: 2 additions & 5 deletions src/java.base/share/classes/java/util/AbstractList.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,7 @@ public Spliterator<E> trySplit() {
new RandomAccessSpliterator<>(this, lo, index = mid);
}

public boolean tryAdvance(Consumer<? super E> action) {
if (action == null)
throw new NullPointerException();
public boolean tryAdvance(Consumer<? super E>! action) {
int hi = getFence(), i = index;
if (i < hi) {
index = i + 1;
Expand All @@ -712,8 +710,7 @@ public boolean tryAdvance(Consumer<? super E> action) {
return false;
}

public void forEachRemaining(Consumer<? super E> action) {
Objects.requireNonNull(action);
public void forEachRemaining(Consumer<? super E>! action) {
List<E> lst = list;
int hi = getFence();
int i = index;
Expand Down
7 changes: 2 additions & 5 deletions src/java.base/share/classes/java/util/ArrayDeque.java
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,7 @@ public DeqSpliterator trySplit() {
: new DeqSpliterator(i, cursor = inc(i, n, es.length));
}

public void forEachRemaining(Consumer<? super E> action) {
if (action == null)
throw new NullPointerException();
public void forEachRemaining(Consumer<? super E>! action) {
final int end = getFence(), cursor = this.cursor;
final Object[] es = elements;
if (cursor != end) {
Expand All @@ -849,8 +847,7 @@ public void forEachRemaining(Consumer<? super E> action) {
}
}

public boolean tryAdvance(Consumer<? super E> action) {
Objects.requireNonNull(action);
public boolean tryAdvance(Consumer<? super E>! action) {
final Object[] es = elements;
if (fence < 0) { fence = tail; cursor = head; } // late-binding
final int i;
Expand Down
14 changes: 4 additions & 10 deletions src/java.base/share/classes/java/util/ArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,7 @@ public ArrayList<E>.ArrayListSpliterator trySplit() {
root.new ArrayListSpliterator(lo, index = mid, expectedModCount);
}

public boolean tryAdvance(Consumer<? super E> action) {
Objects.requireNonNull(action);
public boolean tryAdvance(Consumer<? super E>! action) {
int hi = getFence(), i = index;
if (i < hi) {
index = i + 1;
Expand All @@ -1557,8 +1556,7 @@ public boolean tryAdvance(Consumer<? super E> action) {
return false;
}

public void forEachRemaining(Consumer<? super E> action) {
Objects.requireNonNull(action);
public void forEachRemaining(Consumer<? super E>! action) {
int i, hi, mc; // hoist accesses and checks from loop
ArrayList<E> lst = root;
Object[] a;
Expand Down Expand Up @@ -1691,9 +1689,7 @@ public ArrayListSpliterator trySplit() {
new ArrayListSpliterator(lo, index = mid, expectedModCount);
}

public boolean tryAdvance(Consumer<? super E> action) {
if (action == null)
throw new NullPointerException();
public boolean tryAdvance(Consumer<? super E>! action) {
int hi = getFence(), i = index;
if (i < hi) {
index = i + 1;
Expand All @@ -1706,11 +1702,9 @@ public boolean tryAdvance(Consumer<? super E> action) {
return false;
}

public void forEachRemaining(Consumer<? super E> action) {
public void forEachRemaining(Consumer<? super E>! action) {
int i, hi, mc; // hoist accesses and checks from loop
Object[] a;
if (action == null)
throw new NullPointerException();
if ((a = elementData) != null) {
if ((hi = fence) < 0) {
mc = modCount;
Expand Down
6 changes: 2 additions & 4 deletions src/java.base/share/classes/java/util/BitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1257,8 +1257,7 @@ private int getFence() {
}

@Override
public boolean tryAdvance(IntConsumer action) {
Objects.requireNonNull(action);
public boolean tryAdvance(IntConsumer! action) {

int hi = getFence();
int i = index;
Expand All @@ -1278,8 +1277,7 @@ public boolean tryAdvance(IntConsumer action) {
}

@Override
public void forEachRemaining(IntConsumer action) {
Objects.requireNonNull(action);
public void forEachRemaining(IntConsumer! action) {

int hi = getFence();
int i = index;
Expand Down
11 changes: 4 additions & 7 deletions src/java.base/share/classes/java/util/Collections.java
Original file line number Diff line number Diff line change
Expand Up @@ -1799,14 +1799,12 @@ static final class UnmodifiableEntrySetSpliterator<K, V>
}

@Override
public boolean tryAdvance(Consumer<? super Entry<K, V>> action) {
Objects.requireNonNull(action);
public boolean tryAdvance(Consumer<? super Entry<K, V>>! action) {
return s.tryAdvance(entryConsumer(action));
}

@Override
public void forEachRemaining(Consumer<? super Entry<K, V>> action) {
Objects.requireNonNull(action);
public void forEachRemaining(Consumer<? super Entry<K, V>>! action) {
s.forEachRemaining(entryConsumer(action));
}

Expand Down Expand Up @@ -5182,8 +5180,7 @@ public Spliterator<T> trySplit() {
}

@Override
public boolean tryAdvance(Consumer<? super T> consumer) {
Objects.requireNonNull(consumer);
public boolean tryAdvance(Consumer<? super T>! consumer) {
if (est > 0) {
est--;
consumer.accept(element);
Expand All @@ -5193,7 +5190,7 @@ public boolean tryAdvance(Consumer<? super T> consumer) {
}

@Override
public void forEachRemaining(Consumer<? super T> consumer) {
public void forEachRemaining(Consumer<? super T>! consumer) {
tryAdvance(consumer);
}

Expand Down
24 changes: 6 additions & 18 deletions src/java.base/share/classes/java/util/HashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -1693,10 +1693,8 @@ public KeySpliterator<K,V> trySplit() {
expectedModCount);
}

public void forEachRemaining(Consumer<? super K> action) {
public void forEachRemaining(Consumer<? super K>! action) {
int i, hi, mc;
if (action == null)
throw new NullPointerException();
HashMap<K,V> m = map;
Node<K,V>[] tab = m.table;
if ((hi = fence) < 0) {
Expand All @@ -1722,10 +1720,8 @@ public void forEachRemaining(Consumer<? super K> action) {
}
}

public boolean tryAdvance(Consumer<? super K> action) {
public boolean tryAdvance(Consumer<? super K>! action) {
int hi;
if (action == null)
throw new NullPointerException();
Node<K,V>[] tab = map.table;
if (tab != null && tab.length >= (hi = getFence()) && index >= 0) {
while (current != null || index < hi) {
Expand Down Expand Up @@ -1765,10 +1761,8 @@ public ValueSpliterator<K,V> trySplit() {
expectedModCount);
}

public void forEachRemaining(Consumer<? super V> action) {
public void forEachRemaining(Consumer<? super V>! action) {
int i, hi, mc;
if (action == null)
throw new NullPointerException();
HashMap<K,V> m = map;
Node<K,V>[] tab = m.table;
if ((hi = fence) < 0) {
Expand All @@ -1794,10 +1788,8 @@ public void forEachRemaining(Consumer<? super V> action) {
}
}

public boolean tryAdvance(Consumer<? super V> action) {
public boolean tryAdvance(Consumer<? super V>! action) {
int hi;
if (action == null)
throw new NullPointerException();
Node<K,V>[] tab = map.table;
if (tab != null && tab.length >= (hi = getFence()) && index >= 0) {
while (current != null || index < hi) {
Expand Down Expand Up @@ -1836,10 +1828,8 @@ public EntrySpliterator<K,V> trySplit() {
expectedModCount);
}

public void forEachRemaining(Consumer<? super Map.Entry<K,V>> action) {
public void forEachRemaining(Consumer<? super Map.Entry<K,V>>! action) {
int i, hi, mc;
if (action == null)
throw new NullPointerException();
HashMap<K,V> m = map;
Node<K,V>[] tab = m.table;
if ((hi = fence) < 0) {
Expand All @@ -1865,10 +1855,8 @@ public void forEachRemaining(Consumer<? super Map.Entry<K,V>> action) {
}
}

public boolean tryAdvance(Consumer<? super Map.Entry<K,V>> action) {
public boolean tryAdvance(Consumer<? super Map.Entry<K,V>>! action) {
int hi;
if (action == null)
throw new NullPointerException();
Node<K,V>[] tab = map.table;
if (tab != null && tab.length >= (hi = getFence()) && index >= 0) {
while (current != null || index < hi) {
Expand Down
Loading