From 398c2b9eb348d7b21083a5abf155eee5f2a5132e Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Fri, 2 Oct 2026 23:40:43 -0400 Subject: [PATCH] Rename Shrinkable to CanShrink, as in typetools/jdk Checker Framework 3.53.1 renamed the index qualifiers Shrinkable and UncheckedShrinkable to CanShrink and UncheckedCanShrink (typetools/jdk commit a40bbefdcdb). Apply the rename here as on master (eisop/jdk#161), and align UncheckedCanShrink.java and Prefix.java with the Checker Framework for the JDK consistency check. Co-Authored-By: Claude Sonnet 5.5 --- .../classes/java/util/AbstractCollection.java | 10 ++-- .../share/classes/java/util/AbstractList.java | 8 +-- .../classes/java/util/AbstractQueue.java | 6 +-- .../java/util/AbstractSequentialList.java | 4 +- .../share/classes/java/util/ArrayDeque.java | 30 +++++------ .../share/classes/java/util/ArrayList.java | 18 +++---- .../share/classes/java/util/Collection.java | 12 ++--- .../share/classes/java/util/Deque.java | 26 +++++----- .../share/classes/java/util/Iterator.java | 4 +- .../share/classes/java/util/LinkedList.java | 26 +++++----- .../share/classes/java/util/List.java | 12 ++--- .../classes/java/util/PriorityQueue.java | 18 +++---- .../share/classes/java/util/Queue.java | 6 +-- .../share/classes/java/util/Stack.java | 4 +- .../share/classes/java/util/Vector.java | 24 ++++----- .../util/concurrent/ArrayBlockingQueue.java | 22 ++++---- .../java/util/concurrent/BlockingDeque.java | 24 ++++----- .../java/util/concurrent/BlockingQueue.java | 8 +-- .../concurrent/ConcurrentLinkedDeque.java | 30 +++++------ .../concurrent/ConcurrentLinkedQueue.java | 14 ++--- .../util/concurrent/CopyOnWriteArrayList.java | 18 +++---- .../java/util/concurrent/DelayQueue.java | 16 +++--- .../util/concurrent/LinkedBlockingDeque.java | 52 +++++++++---------- .../util/concurrent/LinkedBlockingQueue.java | 22 ++++---- .../util/concurrent/LinkedTransferQueue.java | 28 +++++----- .../concurrent/PriorityBlockingQueue.java | 22 ++++---- .../util/concurrent/SynchronousQueue.java | 20 +++---- .../checker/index/qual/BottomGrowShrink.java | 2 +- .../qual/{Shrinkable.java => CanShrink.java} | 4 +- ...hrinkable.java => UncheckedCanShrink.java} | 10 ++-- .../checker/units/qual/Prefix.java | 2 +- 31 files changed, 251 insertions(+), 251 deletions(-) rename src/java.base/share/classes/org/checkerframework/checker/index/qual/{Shrinkable.java => CanShrink.java} (81%) rename src/java.base/share/classes/org/checkerframework/checker/index/qual/{UncheckedShrinkable.java => UncheckedCanShrink.java} (73%) diff --git a/src/java.base/share/classes/java/util/AbstractCollection.java b/src/java.base/share/classes/java/util/AbstractCollection.java index 87cc5edd01d..72553ea9e91 100644 --- a/src/java.base/share/classes/java/util/AbstractCollection.java +++ b/src/java.base/share/classes/java/util/AbstractCollection.java @@ -27,7 +27,7 @@ import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; import org.checkerframework.checker.nonempty.qual.PolyNonEmpty; @@ -296,7 +296,7 @@ public boolean add(@GuardSatisfied AbstractCollection this, E e) { * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ - public boolean remove(@GuardSatisfied @Shrinkable AbstractCollection this, @GuardSatisfied @UnknownSignedness Object o) { + public boolean remove(@GuardSatisfied @CanShrink AbstractCollection this, @GuardSatisfied @UnknownSignedness Object o) { Iterator it = iterator(); if (o==null) { while (it.hasNext()) { @@ -389,7 +389,7 @@ public boolean addAll(@GuardSatisfied AbstractCollection this, Collection this, Collection c) { + public boolean removeAll(@GuardSatisfied @CanShrink AbstractCollection this, Collection c) { Objects.requireNonNull(c); boolean modified = false; Iterator it = iterator(); @@ -424,7 +424,7 @@ public boolean removeAll(@GuardSatisfied @Shrinkable AbstractCollection this, * @see #remove(Object) * @see #contains(Object) */ - public boolean retainAll(@GuardSatisfied @Shrinkable AbstractCollection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink AbstractCollection this, Collection c) { Objects.requireNonNull(c); boolean modified = false; Iterator it = iterator(); @@ -453,7 +453,7 @@ public boolean retainAll(@GuardSatisfied @Shrinkable AbstractCollection this, * * @throws UnsupportedOperationException {@inheritDoc} */ - public void clear(@GuardSatisfied @Shrinkable AbstractCollection this) { + public void clear(@GuardSatisfied @CanShrink AbstractCollection this) { Iterator it = iterator(); while (it.hasNext()) { it.next(); diff --git a/src/java.base/share/classes/java/util/AbstractList.java b/src/java.base/share/classes/java/util/AbstractList.java index 01d5928725c..3fb279fa310 100644 --- a/src/java.base/share/classes/java/util/AbstractList.java +++ b/src/java.base/share/classes/java/util/AbstractList.java @@ -29,7 +29,7 @@ import org.checkerframework.checker.index.qual.IndexFor; import org.checkerframework.checker.index.qual.IndexOrHigh; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -187,7 +187,7 @@ public void add(@GuardSatisfied AbstractList this, @IndexOrHigh({"this"}) int * @throws UnsupportedOperationException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ - public E remove(@GuardSatisfied @Shrinkable AbstractList this, @IndexFor({"this"}) int index) { + public E remove(@GuardSatisfied @CanShrink AbstractList this, @IndexFor({"this"}) int index) { throw new UnsupportedOperationException(); } @@ -265,7 +265,7 @@ public E remove(@GuardSatisfied @Shrinkable AbstractList this, @IndexFor({"th * @throws UnsupportedOperationException if the {@code clear} operation * is not supported by this list */ - public void clear(@GuardSatisfied @Shrinkable AbstractList this) { + public void clear(@GuardSatisfied @CanShrink AbstractList this) { removeRange(0, size()); } @@ -623,7 +623,7 @@ public int hashCode(@GuardSatisfied AbstractList this) { * @param fromIndex index of first element to be removed * @param toIndex index after last element to be removed */ - protected void removeRange(@GuardSatisfied @Shrinkable AbstractList this, @IndexOrHigh({"this"}) int fromIndex, @IndexOrHigh({"this"}) int toIndex) { + protected void removeRange(@GuardSatisfied @CanShrink AbstractList this, @IndexOrHigh({"this"}) int fromIndex, @IndexOrHigh({"this"}) int toIndex) { ListIterator it = listIterator(fromIndex); for (int i=0, n=toIndex-fromIndex; i this, E e) { * @return the head of this queue * @throws NoSuchElementException if this queue is empty */ - public E remove(@GuardSatisfied @NonEmpty @Shrinkable AbstractQueue this) { + public E remove(@GuardSatisfied @NonEmpty @CanShrink AbstractQueue this) { E x = poll(); if (x != null) return x; @@ -151,7 +151,7 @@ public E element(@GuardSatisfied @NonEmpty AbstractQueue this) { *

This implementation repeatedly invokes {@link #poll poll} until it * returns {@code null}. */ - public void clear(@GuardSatisfied @Shrinkable AbstractQueue this) { + public void clear(@GuardSatisfied @CanShrink AbstractQueue this) { while (poll() != null) ; } diff --git a/src/java.base/share/classes/java/util/AbstractSequentialList.java b/src/java.base/share/classes/java/util/AbstractSequentialList.java index dfa76cdf439..b152e73727a 100644 --- a/src/java.base/share/classes/java/util/AbstractSequentialList.java +++ b/src/java.base/share/classes/java/util/AbstractSequentialList.java @@ -26,7 +26,7 @@ package java.util; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.PolyNonEmpty; import org.checkerframework.dataflow.qual.Pure; @@ -180,7 +180,7 @@ public void add(@GuardSatisfied AbstractSequentialList this, int index, E ele * @throws UnsupportedOperationException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ - public E remove(@GuardSatisfied @Shrinkable AbstractSequentialList this, int index) { + public E remove(@GuardSatisfied @CanShrink AbstractSequentialList this, int index) { try { ListIterator e = listIterator(index); E outCast = e.next(); diff --git a/src/java.base/share/classes/java/util/ArrayDeque.java b/src/java.base/share/classes/java/util/ArrayDeque.java index fd4351a35ef..5f878924d6b 100644 --- a/src/java.base/share/classes/java/util/ArrayDeque.java +++ b/src/java.base/share/classes/java/util/ArrayDeque.java @@ -36,7 +36,7 @@ import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -375,7 +375,7 @@ public boolean offerLast(E e) { /** * @throws NoSuchElementException {@inheritDoc} */ - public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { + public E removeFirst(@GuardSatisfied @NonEmpty @CanShrink ArrayDeque this) { E e = pollFirst(); if (e == null) throw new NoSuchElementException(); @@ -385,14 +385,14 @@ public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { /** * @throws NoSuchElementException {@inheritDoc} */ - public E removeLast(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { + public E removeLast(@GuardSatisfied @NonEmpty @CanShrink ArrayDeque this) { E e = pollLast(); if (e == null) throw new NoSuchElementException(); return e; } - public @Nullable E pollFirst(@GuardSatisfied @Shrinkable ArrayDeque this) { + public @Nullable E pollFirst(@GuardSatisfied @CanShrink ArrayDeque this) { final Object[] es; final int h; E e = elementAt(es = elements, h = head); @@ -403,7 +403,7 @@ public E removeLast(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { return e; } - public @Nullable E pollLast(@GuardSatisfied @Shrinkable ArrayDeque this) { + public @Nullable E pollLast(@GuardSatisfied @CanShrink ArrayDeque this) { final Object[] es; final int t; E e = elementAt(es = elements, t = dec(tail, es.length)); @@ -456,7 +456,7 @@ public E getLast(@GuardSatisfied @NonEmpty ArrayDeque this) { * @param o element to be removed from this deque, if present * @return {@code true} if the deque contained the specified element */ - public boolean removeFirstOccurrence(@GuardSatisfied @Shrinkable ArrayDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean removeFirstOccurrence(@GuardSatisfied @CanShrink ArrayDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o != null) { final Object[] es = elements; for (int i = head, end = tail, to = (i <= end) ? end : es.length; @@ -484,7 +484,7 @@ public boolean removeFirstOccurrence(@GuardSatisfied @Shrinkable ArrayDeque t * @param o element to be removed from this deque, if present * @return {@code true} if the deque contained the specified element */ - public boolean removeLastOccurrence(@GuardSatisfied @Shrinkable ArrayDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean removeLastOccurrence(@GuardSatisfied @CanShrink ArrayDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o != null) { final Object[] es = elements; for (int i = tail, end = head, to = (i >= end) ? end : 0; @@ -541,7 +541,7 @@ public boolean offer(@GuardSatisfied ArrayDeque this, E e) { * @return the head of the queue represented by this deque * @throws NoSuchElementException {@inheritDoc} */ - public E remove(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { + public E remove(@GuardSatisfied @NonEmpty @CanShrink ArrayDeque this) { return removeFirst(); } @@ -555,7 +555,7 @@ public E remove(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { * @return the head of the queue represented by this deque, or * {@code null} if this deque is empty */ - public @Nullable E poll(@GuardSatisfied @Shrinkable ArrayDeque this) { + public @Nullable E poll(@GuardSatisfied @CanShrink ArrayDeque this) { return pollFirst(); } @@ -612,7 +612,7 @@ public void push(@GuardSatisfied ArrayDeque this, E e) { * of the stack represented by this deque) * @throws NoSuchElementException {@inheritDoc} */ - public E pop(@GuardSatisfied @NonEmpty @Shrinkable ArrayDeque this) { + public E pop(@GuardSatisfied @NonEmpty @CanShrink ArrayDeque this) { return removeFirst(); } @@ -926,7 +926,7 @@ public void forEach(Consumer action) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable ArrayDeque this, Predicate filter) { + public boolean removeIf(@CanShrink ArrayDeque this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -934,7 +934,7 @@ public boolean removeIf(@Shrinkable ArrayDeque this, Predicate fil /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeAll(@Shrinkable ArrayDeque this, Collection c) { + public boolean removeAll(@CanShrink ArrayDeque this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -942,7 +942,7 @@ public boolean removeAll(@Shrinkable ArrayDeque this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink ArrayDeque this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } @@ -1058,7 +1058,7 @@ public boolean contains(@GuardSatisfied ArrayDeque this, @GuardSatisfied @Nul * @param o element to be removed from this deque, if present * @return {@code true} if this deque contained the specified element */ - public boolean remove(@GuardSatisfied @Shrinkable ArrayDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@GuardSatisfied @CanShrink ArrayDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { return removeFirstOccurrence(o); } @@ -1066,7 +1066,7 @@ public boolean remove(@GuardSatisfied @Shrinkable ArrayDeque this, @GuardSati * Removes all of the elements from this deque. * The deque will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable ArrayDeque this) { + public void clear(@GuardSatisfied @CanShrink ArrayDeque this) { circularClear(elements, head, tail); head = tail = 0; } diff --git a/src/java.base/share/classes/java/util/ArrayList.java b/src/java.base/share/classes/java/util/ArrayList.java index eab7ee3ccd5..c8c33124587 100644 --- a/src/java.base/share/classes/java/util/ArrayList.java +++ b/src/java.base/share/classes/java/util/ArrayList.java @@ -28,7 +28,7 @@ import org.checkerframework.checker.index.qual.GTENegativeOne; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -584,7 +584,7 @@ public void addLast(E element) { * @return the element that was removed from the list * @throws IndexOutOfBoundsException {@inheritDoc} */ - public E remove(@GuardSatisfied @Shrinkable ArrayList this, @NonNegative int index) { + public E remove(@GuardSatisfied @CanShrink ArrayList this, @NonNegative int index) { Objects.checkIndex(index, size); final Object[] es = elementData; @@ -731,7 +731,7 @@ int hashCodeRange(int from, int to) { * @param o element to be removed from this list, if present * @return {@code true} if this list contained the specified element */ - public boolean remove(@GuardSatisfied @Shrinkable ArrayList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@GuardSatisfied @CanShrink ArrayList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { final Object[] es = elementData; final int size = this.size; int i = 0; @@ -767,7 +767,7 @@ private void fastRemove(Object[] es, int i) { * Removes all of the elements from this list. The list will * be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable ArrayList this) { + public void clear(@GuardSatisfied @CanShrink ArrayList this) { modCount++; final Object[] es = elementData; for (int to = size, i = size = 0; i < to; i++) @@ -853,7 +853,7 @@ public boolean addAll(@GuardSatisfied ArrayList this, @NonNegative int index, * toIndex > size() || * toIndex < fromIndex}) */ - protected void removeRange(@GuardSatisfied @Shrinkable ArrayList this, int fromIndex, int toIndex) { + protected void removeRange(@GuardSatisfied @CanShrink ArrayList this, int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IndexOutOfBoundsException( outOfBoundsMsg(fromIndex, toIndex)); @@ -908,7 +908,7 @@ private static String outOfBoundsMsg(int fromIndex, int toIndex) { * or if the specified collection is null * @see Collection#contains(Object) */ - public boolean removeAll(@Shrinkable ArrayList this, Collection c) { + public boolean removeAll(@CanShrink ArrayList this, Collection c) { return batchRemove(c, false, 0, size); } @@ -928,7 +928,7 @@ public boolean removeAll(@Shrinkable ArrayList this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink ArrayList this, Collection c) { return batchRemove(c, true, 0, size); } @@ -1789,7 +1789,7 @@ private static boolean isClear(long[] bits, int i) { * @throws NullPointerException {@inheritDoc} */ @Override - public boolean removeIf(@Shrinkable ArrayList this, Predicate filter) { + public boolean removeIf(@CanShrink ArrayList this, Predicate filter) { return removeIf(filter, 0, size); } @@ -1797,7 +1797,7 @@ public boolean removeIf(@Shrinkable ArrayList this, Predicate filt * Removes all elements satisfying the given predicate, from index * i (inclusive) to index end (exclusive). */ - boolean removeIf(@Shrinkable ArrayList this, Predicate filter, int i, final int end) { + boolean removeIf(@CanShrink ArrayList this, Predicate filter, int i, final int end) { Objects.requireNonNull(filter); int expectedModCount = modCount; final Object[] es = elementData; diff --git a/src/java.base/share/classes/java/util/Collection.java b/src/java.base/share/classes/java/util/Collection.java index c8f14803210..5e5534bcf05 100644 --- a/src/java.base/share/classes/java/util/Collection.java +++ b/src/java.base/share/classes/java/util/Collection.java @@ -27,7 +27,7 @@ import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -510,7 +510,7 @@ default T[] toArray(IntFunction generator) { * @throws UnsupportedOperationException if the {@code remove} operation * is not supported by this collection */ - boolean remove(@GuardSatisfied @Shrinkable Collection this, @UnknownSignedness Object o); + boolean remove(@GuardSatisfied @CanShrink Collection this, @UnknownSignedness Object o); // Bulk Operations @@ -587,7 +587,7 @@ default T[] toArray(IntFunction generator) { * @see #remove(Object) * @see #contains(Object) */ - boolean removeAll(@GuardSatisfied @Shrinkable Collection this, Collection c); + boolean removeAll(@GuardSatisfied @CanShrink Collection this, Collection c); /** * Removes all of the elements of this collection that satisfy the given @@ -611,7 +611,7 @@ default T[] toArray(IntFunction generator) { * supported. * @since 1.8 */ - default boolean removeIf(@Shrinkable Collection this, Predicate filter) { + default boolean removeIf(@CanShrink Collection this, Predicate filter) { Objects.requireNonNull(filter); boolean removed = false; final Iterator each = iterator(); @@ -646,7 +646,7 @@ default boolean removeIf(@Shrinkable Collection this, Predicate fi * @see #remove(Object) * @see #contains(Object) */ - boolean retainAll(@GuardSatisfied @Shrinkable Collection this, Collection c); + boolean retainAll(@GuardSatisfied @CanShrink Collection this, Collection c); /** * Removes all of the elements from this collection (optional operation). @@ -655,7 +655,7 @@ default boolean removeIf(@Shrinkable Collection this, Predicate fi * @throws UnsupportedOperationException if the {@code clear} operation * is not supported by this collection */ - void clear(@GuardSatisfied @Shrinkable Collection this); + void clear(@GuardSatisfied @CanShrink Collection this); // Comparison and hashing diff --git a/src/java.base/share/classes/java/util/Deque.java b/src/java.base/share/classes/java/util/Deque.java index 385575bb9bf..52c70ee55df 100644 --- a/src/java.base/share/classes/java/util/Deque.java +++ b/src/java.base/share/classes/java/util/Deque.java @@ -37,7 +37,7 @@ import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -305,7 +305,7 @@ public interface Deque extends Queue, SequencedCollection { * @return the head of this deque * @throws NoSuchElementException if this deque is empty */ - E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable Deque this); + E removeFirst(@GuardSatisfied @NonEmpty @CanShrink Deque this); /** * Retrieves and removes the last element of this deque. This method @@ -315,7 +315,7 @@ public interface Deque extends Queue, SequencedCollection { * @return the tail of this deque * @throws NoSuchElementException if this deque is empty */ - E removeLast(@GuardSatisfied @NonEmpty @Shrinkable Deque this); + E removeLast(@GuardSatisfied @NonEmpty @CanShrink Deque this); /** * Retrieves and removes the first element of this deque, @@ -323,7 +323,7 @@ public interface Deque extends Queue, SequencedCollection { * * @return the head of this deque, or {@code null} if this deque is empty */ - @Nullable E pollFirst(@GuardSatisfied @Shrinkable Deque this); + @Nullable E pollFirst(@GuardSatisfied @CanShrink Deque this); /** * Retrieves and removes the last element of this deque, @@ -331,7 +331,7 @@ public interface Deque extends Queue, SequencedCollection { * * @return the tail of this deque, or {@code null} if this deque is empty */ - @Nullable E pollLast(@GuardSatisfied @Shrinkable Deque this); + @Nullable E pollLast(@GuardSatisfied @CanShrink Deque this); /** * Retrieves, but does not remove, the first element of this deque. @@ -343,7 +343,7 @@ public interface Deque extends Queue, SequencedCollection { * @throws NoSuchElementException if this deque is empty */ @EnsuresNonEmpty("this") - E getFirst(@GuardSatisfied @NonEmpty @Shrinkable Deque this); + E getFirst(@GuardSatisfied @NonEmpty @CanShrink Deque this); /** * Retrieves, but does not remove, the last element of this deque. @@ -354,7 +354,7 @@ public interface Deque extends Queue, SequencedCollection { * @throws NoSuchElementException if this deque is empty */ @EnsuresNonEmpty("this") - E getLast(@GuardSatisfied @NonEmpty @Shrinkable Deque this); + E getLast(@GuardSatisfied @NonEmpty @CanShrink Deque this); /** * Retrieves, but does not remove, the first element of this deque, @@ -391,7 +391,7 @@ public interface Deque extends Queue, SequencedCollection { * deque does not permit null elements * ({@linkplain Collection##optional-restrictions optional}) */ - boolean removeFirstOccurrence(@GuardSatisfied @Shrinkable Deque this, Object o); + boolean removeFirstOccurrence(@GuardSatisfied @CanShrink Deque this, Object o); /** * Removes the last occurrence of the specified element from this deque. @@ -410,7 +410,7 @@ public interface Deque extends Queue, SequencedCollection { * deque does not permit null elements * ({@linkplain Collection##optional-restrictions optional}) */ - boolean removeLastOccurrence(@GuardSatisfied @Shrinkable Deque this, Object o); + boolean removeLastOccurrence(@GuardSatisfied @CanShrink Deque this, Object o); // *** Queue methods *** @@ -473,7 +473,7 @@ public interface Deque extends Queue, SequencedCollection { * @return the head of the queue represented by this deque * @throws NoSuchElementException if this deque is empty */ - E remove(@GuardSatisfied @NonEmpty @Shrinkable Deque this); + E remove(@GuardSatisfied @NonEmpty @CanShrink Deque this); /** * Retrieves and removes the head of the queue represented by this deque @@ -485,7 +485,7 @@ public interface Deque extends Queue, SequencedCollection { * @return the first element of this deque, or {@code null} if * this deque is empty */ - @Nullable E poll(@GuardSatisfied @Shrinkable Deque this); + @Nullable E poll(@GuardSatisfied @CanShrink Deque this); /** * Retrieves, but does not remove, the head of the queue represented by @@ -571,7 +571,7 @@ public interface Deque extends Queue, SequencedCollection { * of the stack represented by this deque) * @throws NoSuchElementException if this deque is empty */ - E pop(@GuardSatisfied @NonEmpty @Shrinkable Deque this); + E pop(@GuardSatisfied @NonEmpty @CanShrink Deque this); // *** Collection methods *** @@ -595,7 +595,7 @@ public interface Deque extends Queue, SequencedCollection { * deque does not permit null elements * ({@linkplain Collection##optional-restrictions optional}) */ - boolean remove(@GuardSatisfied @Shrinkable Deque this, @UnknownSignedness Object o); + boolean remove(@GuardSatisfied @CanShrink Deque this, @UnknownSignedness Object o); /** * Returns {@code true} if this deque contains the specified element. diff --git a/src/java.base/share/classes/java/util/Iterator.java b/src/java.base/share/classes/java/util/Iterator.java index 6bff1b79443..ea161c91051 100644 --- a/src/java.base/share/classes/java/util/Iterator.java +++ b/src/java.base/share/classes/java/util/Iterator.java @@ -25,7 +25,7 @@ package java.util; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; import org.checkerframework.checker.nonempty.qual.NonEmpty; @@ -114,7 +114,7 @@ public interface Iterator { * been called after the last call to the {@code next} * method */ - default void remove(@GuardSatisfied @Shrinkable Iterator this) { + default void remove(@GuardSatisfied @CanShrink Iterator this) { throw new UnsupportedOperationException("remove"); } diff --git a/src/java.base/share/classes/java/util/LinkedList.java b/src/java.base/share/classes/java/util/LinkedList.java index f079b134dab..3e35cfc1717 100644 --- a/src/java.base/share/classes/java/util/LinkedList.java +++ b/src/java.base/share/classes/java/util/LinkedList.java @@ -28,7 +28,7 @@ import org.checkerframework.checker.index.qual.GTENegativeOne; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.lock.qual.ReleasesNoLocks; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; @@ -296,7 +296,7 @@ public E getLast(@GuardSatisfied @NonEmpty LinkedList this) { * @return the first element from this list * @throws NoSuchElementException if this list is empty */ - public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable LinkedList this) { + public E removeFirst(@GuardSatisfied @NonEmpty @CanShrink LinkedList this) { final Node f = first; if (f == null) throw new NoSuchElementException(); @@ -309,7 +309,7 @@ public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable LinkedList this) { * @return the last element from this list * @throws NoSuchElementException if this list is empty */ - public E removeLast(@GuardSatisfied @NonEmpty @Shrinkable LinkedList this) { + public E removeLast(@GuardSatisfied @NonEmpty @CanShrink LinkedList this) { final Node l = last; if (l == null) throw new NoSuchElementException(); @@ -390,7 +390,7 @@ public boolean add(@GuardSatisfied LinkedList this, E e) { * @return {@code true} if this list contained the specified element */ @ReleasesNoLocks - public boolean remove(@GuardSatisfied @Shrinkable LinkedList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@GuardSatisfied @CanShrink LinkedList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o == null) { for (Node x = first; x != null; x = x.next) { if (x.item == null) { @@ -483,7 +483,7 @@ public boolean addAll(@GuardSatisfied LinkedList this, @NonNegative int index * Removes all of the elements from this list. * The list will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable LinkedList this) { + public void clear(@GuardSatisfied @CanShrink LinkedList this) { // Clearing all of the links between nodes is "unnecessary", but: // - helps a generational GC if the discarded nodes inhabit // more than one generation @@ -560,7 +560,7 @@ public void add(@GuardSatisfied LinkedList this, @NonNegative int index, E el * @return the element previously at the specified position * @throws IndexOutOfBoundsException {@inheritDoc} */ - public E remove(@GuardSatisfied @Shrinkable LinkedList this, @NonNegative int index) { + public E remove(@GuardSatisfied @CanShrink LinkedList this, @NonNegative int index) { checkElementIndex(index); return unlink(node(index)); } @@ -711,7 +711,7 @@ public E element(@GuardSatisfied @NonEmpty LinkedList this) { * @return the head of this list, or {@code null} if this list is empty * @since 1.5 */ - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedList this) { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedList this) { final Node f = first; return (f == null) ? null : unlinkFirst(f); } @@ -723,7 +723,7 @@ public E element(@GuardSatisfied @NonEmpty LinkedList this) { * @throws NoSuchElementException if this list is empty * @since 1.5 */ - public E remove(@GuardSatisfied @NonEmpty @Shrinkable LinkedList this) { + public E remove(@GuardSatisfied @NonEmpty @CanShrink LinkedList this) { return removeFirst(); } @@ -799,7 +799,7 @@ public boolean offerLast(E e) { * this list is empty * @since 1.6 */ - public @Nullable E pollFirst(@GuardSatisfied @Shrinkable LinkedList this) { + public @Nullable E pollFirst(@GuardSatisfied @CanShrink LinkedList this) { final Node f = first; return (f == null) ? null : unlinkFirst(f); } @@ -812,7 +812,7 @@ public boolean offerLast(E e) { * this list is empty * @since 1.6 */ - public @Nullable E pollLast(@GuardSatisfied @Shrinkable LinkedList this) { + public @Nullable E pollLast(@GuardSatisfied @CanShrink LinkedList this) { final Node l = last; return (l == null) ? null : unlinkLast(l); } @@ -841,7 +841,7 @@ public void push(@GuardSatisfied LinkedList this, E e) { * @throws NoSuchElementException if this list is empty * @since 1.6 */ - public E pop(@GuardSatisfied @NonEmpty @Shrinkable LinkedList this) { + public E pop(@GuardSatisfied @NonEmpty @CanShrink LinkedList this) { return removeFirst(); } @@ -854,7 +854,7 @@ public E pop(@GuardSatisfied @NonEmpty @Shrinkable LinkedList this) { * @return {@code true} if the list contained the specified element * @since 1.6 */ - public boolean removeFirstOccurrence(@GuardSatisfied @Shrinkable LinkedList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean removeFirstOccurrence(@GuardSatisfied @CanShrink LinkedList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { return remove(o); } @@ -867,7 +867,7 @@ public boolean removeFirstOccurrence(@GuardSatisfied @Shrinkable LinkedList t * @return {@code true} if the list contained the specified element * @since 1.6 */ - public boolean removeLastOccurrence(@GuardSatisfied @Shrinkable LinkedList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean removeLastOccurrence(@GuardSatisfied @CanShrink LinkedList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o == null) { for (Node x = last; x != null; x = x.prev) { if (x.item == null) { diff --git a/src/java.base/share/classes/java/util/List.java b/src/java.base/share/classes/java/util/List.java index 2ffcdeea06a..f4fa988854a 100644 --- a/src/java.base/share/classes/java/util/List.java +++ b/src/java.base/share/classes/java/util/List.java @@ -30,7 +30,7 @@ import org.checkerframework.checker.index.qual.IndexOrHigh; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.lock.qual.ReleasesNoLocks; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; @@ -321,7 +321,7 @@ public interface List extends SequencedCollection { * @throws UnsupportedOperationException if the {@code remove} operation * is not supported by this list */ - boolean remove(@GuardSatisfied @Shrinkable List this, @UnknownSignedness Object o); + boolean remove(@GuardSatisfied @CanShrink List this, @UnknownSignedness Object o); // Bulk Modification Operations @@ -419,7 +419,7 @@ public interface List extends SequencedCollection { * @see #remove(Object) * @see #contains(Object) */ - boolean removeAll(@GuardSatisfied @Shrinkable List this, Collection c); + boolean removeAll(@GuardSatisfied @CanShrink List this, Collection c); /** * Retains only the elements in this list that are contained in the @@ -441,7 +441,7 @@ public interface List extends SequencedCollection { * @see #remove(Object) * @see #contains(Object) */ - boolean retainAll(@GuardSatisfied @Shrinkable List this, Collection c); + boolean retainAll(@GuardSatisfied @CanShrink List this, Collection c); /** * Replaces each element of this list with the result of applying the @@ -557,7 +557,7 @@ default void sort(@Nullable Comparator c) { * @throws UnsupportedOperationException if the {@code clear} operation * is not supported by this list */ - void clear(@GuardSatisfied @Shrinkable List this); + void clear(@GuardSatisfied @CanShrink List this); // Comparison and hashing @@ -669,7 +669,7 @@ default void sort(@Nullable Comparator c) { * ({@code index < 0 || index >= size()}) */ @ReleasesNoLocks - E remove(@GuardSatisfied @Shrinkable List this, @IndexFor({"this"}) int index); + E remove(@GuardSatisfied @CanShrink List this, @IndexFor({"this"}) int index); // Search Operations diff --git a/src/java.base/share/classes/java/util/PriorityQueue.java b/src/java.base/share/classes/java/util/PriorityQueue.java index 9cd7735b994..87a19a37f81 100644 --- a/src/java.base/share/classes/java/util/PriorityQueue.java +++ b/src/java.base/share/classes/java/util/PriorityQueue.java @@ -28,7 +28,7 @@ import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; import org.checkerframework.checker.index.qual.Positive; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -380,7 +380,7 @@ private int indexOf(@GuardSatisfied @Nullable @UnknownSignedness Object o) { * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ - public boolean remove(@GuardSatisfied @Shrinkable PriorityQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@GuardSatisfied @CanShrink PriorityQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { int i = indexOf(o); if (i == -1) return false; @@ -395,7 +395,7 @@ public boolean remove(@GuardSatisfied @Shrinkable PriorityQueue this, @GuardS * * @param o element to be removed from this queue, if present */ - void removeEq(@GuardSatisfied @Shrinkable PriorityQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + void removeEq(@GuardSatisfied @CanShrink PriorityQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { final Object[] es = queue; for (int i = 0, n = size; i < n; i++) { if (o == es[i]) { @@ -591,7 +591,7 @@ public void remove() { * Removes all of the elements from this priority queue. * The queue will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable PriorityQueue this) { + public void clear(@GuardSatisfied @CanShrink PriorityQueue this) { modCount++; final Object[] es = queue; for (int i = 0, n = size; i < n; i++) @@ -599,7 +599,7 @@ public void clear(@GuardSatisfied @Shrinkable PriorityQueue this) { size = 0; } - public @Nullable E poll(@GuardSatisfied @Shrinkable PriorityQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink PriorityQueue this) { final Object[] es; final E result; @@ -631,7 +631,7 @@ public void clear(@GuardSatisfied @Shrinkable PriorityQueue this) { * position before i. This fact is used by iterator.remove so as to * avoid missing traversing elements. */ - E removeAt(@GuardSatisfied @NonEmpty @Shrinkable PriorityQueue this, int i) { + E removeAt(@GuardSatisfied @NonEmpty @CanShrink PriorityQueue this, int i) { // assert i >= 0 && i < size; final Object[] es = queue; modCount++; @@ -922,7 +922,7 @@ public int characteristics() { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@GuardSatisfied @Shrinkable PriorityQueue this, Predicate filter) { + public boolean removeIf(@GuardSatisfied @CanShrink PriorityQueue this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -930,7 +930,7 @@ public boolean removeIf(@GuardSatisfied @Shrinkable PriorityQueue this, Predi /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeAll(@GuardSatisfied @Shrinkable PriorityQueue this, Collection c) { + public boolean removeAll(@GuardSatisfied @CanShrink PriorityQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -938,7 +938,7 @@ public boolean removeAll(@GuardSatisfied @Shrinkable PriorityQueue this, Coll /** * @throws NullPointerException {@inheritDoc} */ - public boolean retainAll(@GuardSatisfied @Shrinkable PriorityQueue this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink PriorityQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/Queue.java b/src/java.base/share/classes/java/util/Queue.java index 81af386824e..6e98b1ba389 100644 --- a/src/java.base/share/classes/java/util/Queue.java +++ b/src/java.base/share/classes/java/util/Queue.java @@ -35,7 +35,7 @@ package java.util; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -195,7 +195,7 @@ public interface Queue extends Collection { * @return the head of this queue * @throws NoSuchElementException if this queue is empty */ - E remove(@GuardSatisfied @NonEmpty @Shrinkable Queue this); + E remove(@GuardSatisfied @NonEmpty @CanShrink Queue this); /** * Retrieves and removes the head of this queue, @@ -203,7 +203,7 @@ public interface Queue extends Collection { * * @return the head of this queue, or {@code null} if this queue is empty */ - @Nullable E poll(@GuardSatisfied @Shrinkable Queue this); + @Nullable E poll(@GuardSatisfied @CanShrink Queue this); /** * Retrieves, but does not remove, the head of this queue. This method diff --git a/src/java.base/share/classes/java/util/Stack.java b/src/java.base/share/classes/java/util/Stack.java index 5b6363abafe..4a960c5b90d 100644 --- a/src/java.base/share/classes/java/util/Stack.java +++ b/src/java.base/share/classes/java/util/Stack.java @@ -25,7 +25,7 @@ package java.util; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; import org.checkerframework.checker.nonempty.qual.NonEmpty; @@ -89,7 +89,7 @@ public E push(@GuardSatisfied Stack this, E item) { * of the {@code Vector} object). * @throws EmptyStackException if this stack is empty. */ - public synchronized E pop(@GuardSatisfied @NonEmpty @Shrinkable Stack this) { + public synchronized E pop(@GuardSatisfied @NonEmpty @CanShrink Stack this) { E obj; int len = size(); diff --git a/src/java.base/share/classes/java/util/Vector.java b/src/java.base/share/classes/java/util/Vector.java index f6a71faefe2..708a7a05d3b 100644 --- a/src/java.base/share/classes/java/util/Vector.java +++ b/src/java.base/share/classes/java/util/Vector.java @@ -28,7 +28,7 @@ import org.checkerframework.checker.index.qual.GTENegativeOne; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -295,7 +295,7 @@ private Object[] grow() { * @param newSize the new size of this vector * @throws ArrayIndexOutOfBoundsException if the new size is negative */ - public synchronized void setSize(@GuardSatisfied @Shrinkable Vector this, @NonNegative int newSize) { + public synchronized void setSize(@GuardSatisfied @CanShrink Vector this, @NonNegative int newSize) { modCount++; if (newSize > elementData.length) grow(newSize); @@ -574,7 +574,7 @@ public synchronized void setElementAt(@GuardSatisfied Vector this, E obj, @No * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) */ - public synchronized void removeElementAt(@GuardSatisfied @Shrinkable Vector this, @NonNegative int index) { + public synchronized void removeElementAt(@GuardSatisfied @CanShrink Vector this, @NonNegative int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); @@ -662,7 +662,7 @@ public synchronized void addElement(@GuardSatisfied Vector this, E obj) { * @return {@code true} if the argument was a component of this * vector; {@code false} otherwise. */ - public synchronized boolean removeElement(@GuardSatisfied @Shrinkable Vector this, Object obj) { + public synchronized boolean removeElement(@GuardSatisfied @CanShrink Vector this, Object obj) { modCount++; int i = indexOf(obj); if (i >= 0) { @@ -678,7 +678,7 @@ public synchronized boolean removeElement(@GuardSatisfied @Shrinkable Vector *

This method is identical in functionality to the {@link #clear} * method (which is part of the {@link List} interface). */ - public synchronized void removeAllElements(@GuardSatisfied @Shrinkable Vector this) { + public synchronized void removeAllElements(@GuardSatisfied @CanShrink Vector this) { final Object[] es = elementData; for (int to = elementCount, i = elementCount = 0; i < to; i++) es[i] = null; @@ -843,7 +843,7 @@ public synchronized boolean add(@GuardSatisfied Vector this, E e) { * @return true if the Vector contained the specified element * @since 1.2 */ - public boolean remove(@GuardSatisfied @Shrinkable Vector this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@GuardSatisfied @CanShrink Vector this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { return removeElement(o); } @@ -873,7 +873,7 @@ public void add(@GuardSatisfied Vector this, @NonNegative int index, E elemen * ({@code index < 0 || index >= size()}) * @since 1.2 */ - public synchronized E remove(@GuardSatisfied @Shrinkable Vector this, @NonNegative int index) { + public synchronized E remove(@GuardSatisfied @CanShrink Vector this, @NonNegative int index) { modCount++; if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); @@ -894,7 +894,7 @@ public synchronized E remove(@GuardSatisfied @Shrinkable Vector this, @NonNeg * * @since 1.2 */ - public void clear(@GuardSatisfied @Shrinkable Vector this) { + public void clear(@GuardSatisfied @CanShrink Vector this) { removeAllElements(); } @@ -962,7 +962,7 @@ public boolean addAll(@GuardSatisfied Vector this, Collection c) * or if the specified collection is null * @since 1.2 */ - public boolean removeAll(@GuardSatisfied @Shrinkable Vector this, Collection c) { + public boolean removeAll(@GuardSatisfied @CanShrink Vector this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -986,7 +986,7 @@ public boolean removeAll(@GuardSatisfied @Shrinkable Vector this, Collection< * or if the specified collection is null * @since 1.2 */ - public boolean retainAll(@GuardSatisfied @Shrinkable Vector this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink Vector this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } @@ -996,7 +996,7 @@ public boolean retainAll(@GuardSatisfied @Shrinkable Vector this, Collection< */ @SuppressWarnings({"unchecked"}) @Override - public boolean removeIf(@Shrinkable Vector this, Predicate filter) { + public boolean removeIf(@CanShrink Vector this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1170,7 +1170,7 @@ public synchronized String toString(@GuardSatisfied Vector this) { * This call shortens the list by {@code (toIndex - fromIndex)} elements. * (If {@code toIndex==fromIndex}, this operation has no effect.) */ - protected synchronized void removeRange(@GuardSatisfied @Shrinkable Vector this, int fromIndex, int toIndex) { + protected synchronized void removeRange(@GuardSatisfied @CanShrink Vector this, int fromIndex, int toIndex) { modCount++; shiftTailOverGap(elementData, fromIndex, toIndex); } diff --git a/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java index 900c6a41c7c..404518b612c 100644 --- a/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -419,7 +419,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) } } - public @Nullable E poll(@GuardSatisfied @Shrinkable ArrayBlockingQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink ArrayBlockingQueue this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -429,7 +429,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) } } - public E take(@GuardSatisfied @Shrinkable ArrayBlockingQueue this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink ArrayBlockingQueue this) throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { @@ -441,7 +441,7 @@ public E take(@GuardSatisfied @Shrinkable ArrayBlockingQueue this) throws Int } } - public @Nullable E poll(@GuardSatisfied @Shrinkable ArrayBlockingQueue this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink ArrayBlockingQueue this, long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); @@ -526,7 +526,7 @@ public int remainingCapacity() { * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ - public boolean remove(@Shrinkable ArrayBlockingQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink ArrayBlockingQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; lock.lock(); @@ -677,7 +677,7 @@ public String toString() { * Atomically removes all of the elements from this queue. * The queue will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable ArrayBlockingQueue this) { + public void clear(@GuardSatisfied @CanShrink ArrayBlockingQueue this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -716,7 +716,7 @@ private static void circularClear(Object[] items, int i, int end) { * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable ArrayBlockingQueue this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink ArrayBlockingQueue this, Collection c) { return drainTo(c, Integer.MAX_VALUE); } @@ -726,7 +726,7 @@ public int drainTo(@GuardSatisfied @Shrinkable ArrayBlockingQueue this, Colle * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable ArrayBlockingQueue this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink ArrayBlockingQueue this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -1491,7 +1491,7 @@ public void forEach(Consumer action) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable ArrayBlockingQueue this, Predicate filter) { + public boolean removeIf(@CanShrink ArrayBlockingQueue this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1499,7 +1499,7 @@ public boolean removeIf(@Shrinkable ArrayBlockingQueue this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink ArrayBlockingQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1507,7 +1507,7 @@ public boolean removeAll(@Shrinkable ArrayBlockingQueue this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink ArrayBlockingQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java b/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java index 6356ee6d378..238062c4f12 100644 --- a/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java +++ b/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -359,7 +359,7 @@ boolean offerLast(E e, long timeout, TimeUnit unit) * @return the head of this deque * @throws InterruptedException if interrupted while waiting */ - E takeFirst(@Shrinkable BlockingDeque this) throws InterruptedException; + E takeFirst(@CanShrink BlockingDeque this) throws InterruptedException; /** * Retrieves and removes the last element of this deque, waiting @@ -368,7 +368,7 @@ boolean offerLast(E e, long timeout, TimeUnit unit) * @return the tail of this deque * @throws InterruptedException if interrupted while waiting */ - E takeLast(@Shrinkable BlockingDeque this) throws InterruptedException; + E takeLast(@CanShrink BlockingDeque this) throws InterruptedException; /** * Retrieves and removes the first element of this deque, waiting @@ -383,7 +383,7 @@ boolean offerLast(E e, long timeout, TimeUnit unit) * waiting time elapses before an element is available * @throws InterruptedException if interrupted while waiting */ - @Nullable E pollFirst(@Shrinkable BlockingDeque this, long timeout, TimeUnit unit) + @Nullable E pollFirst(@CanShrink BlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException; /** @@ -399,7 +399,7 @@ boolean offerLast(E e, long timeout, TimeUnit unit) * waiting time elapses before an element is available * @throws InterruptedException if interrupted while waiting */ - @Nullable E pollLast(@Shrinkable BlockingDeque this, long timeout, TimeUnit unit) + @Nullable E pollLast(@CanShrink BlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException; /** @@ -418,7 +418,7 @@ boolean offerLast(E e, long timeout, TimeUnit unit) * @throws NullPointerException if the specified element is null * (optional) */ - boolean removeFirstOccurrence(@Shrinkable BlockingDeque this, Object o); + boolean removeFirstOccurrence(@CanShrink BlockingDeque this, Object o); /** * Removes the last occurrence of the specified element from this deque. @@ -436,7 +436,7 @@ boolean offerLast(E e, long timeout, TimeUnit unit) * @throws NullPointerException if the specified element is null * (optional) */ - boolean removeLastOccurrence(@Shrinkable BlockingDeque this, Object o); + boolean removeLastOccurrence(@CanShrink BlockingDeque this, Object o); // *** BlockingQueue methods *** @@ -531,7 +531,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * @return the head of the queue represented by this deque * @throws NoSuchElementException if this deque is empty */ - E remove(@GuardSatisfied @NonEmpty @Shrinkable BlockingDeque this); + E remove(@GuardSatisfied @NonEmpty @CanShrink BlockingDeque this); /** * Retrieves and removes the head of the queue represented by this deque @@ -542,7 +542,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * * @return the head of this deque, or {@code null} if this deque is empty */ - @Nullable E poll(@Shrinkable BlockingDeque this); + @Nullable E poll(@CanShrink BlockingDeque this); /** * Retrieves and removes the head of the queue represented by this deque @@ -554,7 +554,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * @return the head of this deque * @throws InterruptedException if interrupted while waiting */ - E take(@Shrinkable BlockingDeque this) throws InterruptedException; + E take(@CanShrink BlockingDeque this) throws InterruptedException; /** * Retrieves and removes the head of the queue represented by this deque @@ -568,7 +568,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * specified waiting time elapses before an element is available * @throws InterruptedException if interrupted while waiting */ - @Nullable E poll(@Shrinkable BlockingDeque this, long timeout, TimeUnit unit) + @Nullable E poll(@CanShrink BlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException; /** @@ -615,7 +615,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * @throws NullPointerException if the specified element is null * (optional) */ - boolean remove(@Shrinkable BlockingDeque this, @UnknownSignedness Object o); + boolean remove(@CanShrink BlockingDeque this, @UnknownSignedness Object o); /** * Returns {@code true} if this deque contains the specified element. diff --git a/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java index 7ad116a16c3..f33a527593e 100644 --- a/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java @@ -35,7 +35,7 @@ package java.util.concurrent; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -319,7 +319,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * @throws NullPointerException if the specified element is null * (optional) */ - boolean remove(@Shrinkable BlockingQueue this, @UnknownSignedness Object o); + boolean remove(@CanShrink BlockingQueue this, @UnknownSignedness Object o); /** * Returns {@code true} if this queue contains the specified element. @@ -361,7 +361,7 @@ boolean offer(E e, long timeout, TimeUnit unit) * queue, or some property of an element of this queue prevents * it from being added to the specified collection */ - int drainTo(@GuardSatisfied @Shrinkable BlockingQueue this, Collection c); + int drainTo(@GuardSatisfied @CanShrink BlockingQueue this, Collection c); /** * Removes at most the given number of available elements from @@ -386,5 +386,5 @@ boolean offer(E e, long timeout, TimeUnit unit) * queue, or some property of an element of this queue prevents * it from being added to the specified collection */ - int drainTo(@GuardSatisfied @Shrinkable BlockingQueue this, Collection c, int maxElements); + int drainTo(@GuardSatisfied @CanShrink BlockingQueue this, Collection c, int maxElements); } diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index e5c0c9964c2..02fc8defca7 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -930,7 +930,7 @@ public E getLast(@NonEmpty ConcurrentLinkedDeque this) { return screenNullResult(peekLast()); } - public @Nullable E pollFirst(@GuardSatisfied @Shrinkable ConcurrentLinkedDeque this) { + public @Nullable E pollFirst(@GuardSatisfied @CanShrink ConcurrentLinkedDeque this) { restart: for (;;) { for (Node first = first(), p = first;;) { final E item; @@ -951,7 +951,7 @@ public E getLast(@NonEmpty ConcurrentLinkedDeque this) { } } - public @Nullable E pollLast(@GuardSatisfied @Shrinkable ConcurrentLinkedDeque this) { + public @Nullable E pollLast(@GuardSatisfied @CanShrink ConcurrentLinkedDeque this) { restart: for (;;) { for (Node last = last(), p = last;;) { final E item; @@ -975,14 +975,14 @@ public E getLast(@NonEmpty ConcurrentLinkedDeque this) { /** * @throws NoSuchElementException {@inheritDoc} */ - public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable ConcurrentLinkedDeque this) { + public E removeFirst(@GuardSatisfied @NonEmpty @CanShrink ConcurrentLinkedDeque this) { return screenNullResult(pollFirst()); } /** * @throws NoSuchElementException {@inheritDoc} */ - public E removeLast(@GuardSatisfied @NonEmpty @Shrinkable ConcurrentLinkedDeque this) { + public E removeLast(@GuardSatisfied @NonEmpty @CanShrink ConcurrentLinkedDeque this) { return screenNullResult(pollLast()); } @@ -1012,19 +1012,19 @@ public boolean add(E e) { return offerLast(e); } - public @Nullable E poll(@Shrinkable ConcurrentLinkedDeque this) { return pollFirst(); } + public @Nullable E poll(@CanShrink ConcurrentLinkedDeque this) { return pollFirst(); } @Pure public @Nullable E peek() { return peekFirst(); } /** * @throws NoSuchElementException {@inheritDoc} */ - public E remove(@NonEmpty @Shrinkable ConcurrentLinkedDeque this) { return removeFirst(); } + public E remove(@NonEmpty @CanShrink ConcurrentLinkedDeque this) { return removeFirst(); } /** * @throws NoSuchElementException {@inheritDoc} */ - public E pop(@GuardSatisfied @NonEmpty @Shrinkable ConcurrentLinkedDeque this) { return removeFirst(); } + public E pop(@GuardSatisfied @NonEmpty @CanShrink ConcurrentLinkedDeque this) { return removeFirst(); } /** * @throws NoSuchElementException {@inheritDoc} @@ -1048,7 +1048,7 @@ public boolean add(E e) { * @return {@code true} if the deque contained the specified element * @throws NullPointerException if the specified element is null */ - public boolean removeFirstOccurrence(@Shrinkable ConcurrentLinkedDeque this, Object o) { + public boolean removeFirstOccurrence(@CanShrink ConcurrentLinkedDeque this, Object o) { Objects.requireNonNull(o); for (Node p = first(); p != null; p = succ(p)) { final E item; @@ -1074,7 +1074,7 @@ public boolean removeFirstOccurrence(@Shrinkable ConcurrentLinkedDeque this, * @return {@code true} if the deque contained the specified element * @throws NullPointerException if the specified element is null */ - public boolean removeLastOccurrence(@Shrinkable ConcurrentLinkedDeque this, Object o) { + public boolean removeLastOccurrence(@CanShrink ConcurrentLinkedDeque this, Object o) { Objects.requireNonNull(o); for (Node p = last(); p != null; p = pred(p)) { final E item; @@ -1166,7 +1166,7 @@ public int size() { * @return {@code true} if the deque contained the specified element * @throws NullPointerException if the specified element is null */ - public boolean remove(@Shrinkable ConcurrentLinkedDeque this, @GuardSatisfied @UnknownSignedness Object o) { + public boolean remove(@CanShrink ConcurrentLinkedDeque this, @GuardSatisfied @UnknownSignedness Object o) { return removeFirstOccurrence(o); } @@ -1236,7 +1236,7 @@ else if (p.prev == p) // NEXT_TERMINATOR /** * Removes all of the elements from this deque. */ - public void clear(@GuardSatisfied @Shrinkable ConcurrentLinkedDeque this) { + public void clear(@GuardSatisfied @CanShrink ConcurrentLinkedDeque this) { while (pollFirst() != null) ; } @@ -1636,7 +1636,7 @@ private void readObject(java.io.ObjectInputStream s) /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable ConcurrentLinkedDeque this, Predicate filter) { + public boolean removeIf(@CanShrink ConcurrentLinkedDeque this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1644,7 +1644,7 @@ public boolean removeIf(@Shrinkable ConcurrentLinkedDeque this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink ConcurrentLinkedDeque this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1652,7 +1652,7 @@ public boolean removeAll(@Shrinkable ConcurrentLinkedDeque this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink ConcurrentLinkedDeque this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index 5f8ccec2186..40962e6b87c 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -398,7 +398,7 @@ else if (p == q) } } - public @Nullable E poll(@GuardSatisfied @Shrinkable ConcurrentLinkedQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink ConcurrentLinkedQueue this) { restartFromHead: for (;;) { for (Node h = head, p = h, q;; p = q) { final E item; @@ -542,7 +542,7 @@ public boolean contains(@GuardSatisfied @UnknownSignedness Object o) { * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ - public boolean remove(@Shrinkable ConcurrentLinkedQueue this, @GuardSatisfied @UnknownSignedness Object o) { + public boolean remove(@CanShrink ConcurrentLinkedQueue this, @GuardSatisfied @UnknownSignedness Object o) { if (o == null) return false; restartFromHead: for (;;) { for (Node p = head, pred = null; p != null; ) { @@ -989,7 +989,7 @@ public Spliterator spliterator() { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable ConcurrentLinkedQueue this, Predicate filter) { + public boolean removeIf(@CanShrink ConcurrentLinkedQueue this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -997,7 +997,7 @@ public boolean removeIf(@Shrinkable ConcurrentLinkedQueue this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink ConcurrentLinkedQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1005,12 +1005,12 @@ public boolean removeAll(@Shrinkable ConcurrentLinkedQueue this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink ConcurrentLinkedQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } - public void clear(@GuardSatisfied @Shrinkable ConcurrentLinkedQueue this) { + public void clear(@GuardSatisfied @CanShrink ConcurrentLinkedQueue this) { bulkRemove(e -> true); } diff --git a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index a88fce84ea7..a54a464a4f7 100644 --- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -35,7 +35,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -546,7 +546,7 @@ public void addLast(E e) { * * @throws IndexOutOfBoundsException {@inheritDoc} */ - public E remove(@GuardSatisfied @Shrinkable CopyOnWriteArrayList this, int index) { + public E remove(@GuardSatisfied @CanShrink CopyOnWriteArrayList this, int index) { synchronized (lock) { Object[] es = getArray(); int len = es.length; @@ -609,7 +609,7 @@ public E removeLast() { * @param o element to be removed from this list, if present * @return {@code true} if this list contained the specified element */ - public boolean remove(@Shrinkable CopyOnWriteArrayList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink CopyOnWriteArrayList this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { Object[] snapshot = getArray(); int index = indexOfRange(o, snapshot, 0, snapshot.length); return index >= 0 && remove(o, snapshot, index); @@ -619,7 +619,7 @@ public boolean remove(@Shrinkable CopyOnWriteArrayList this, @GuardSatisfied * A version of remove(Object) using the strong hint that given * recent snapshot contains o at the given index. */ - private boolean remove(@Shrinkable CopyOnWriteArrayList this, @GuardSatisfied @Nullable @UnknownSignedness Object o, Object[] snapshot, int index) { + private boolean remove(@CanShrink CopyOnWriteArrayList this, @GuardSatisfied @Nullable @UnknownSignedness Object o, Object[] snapshot, int index) { synchronized (lock) { Object[] current = getArray(); int len = current.length; @@ -662,7 +662,7 @@ private boolean remove(@Shrinkable CopyOnWriteArrayList this, @GuardSatisfied * @throws IndexOutOfBoundsException if fromIndex or toIndex out of range * ({@code fromIndex < 0 || toIndex > size() || toIndex < fromIndex}) */ - void removeRange(@GuardSatisfied @Shrinkable CopyOnWriteArrayList this, int fromIndex, int toIndex) { + void removeRange(@GuardSatisfied @CanShrink CopyOnWriteArrayList this, int fromIndex, int toIndex) { synchronized (lock) { Object[] es = getArray(); int len = es.length; @@ -757,7 +757,7 @@ public boolean containsAll(Collection c) { * or if the specified collection is null * @see #remove(Object) */ - public boolean removeAll(@Shrinkable CopyOnWriteArrayList this, Collection c) { + public boolean removeAll(@CanShrink CopyOnWriteArrayList this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -778,7 +778,7 @@ public boolean removeAll(@Shrinkable CopyOnWriteArrayList this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink CopyOnWriteArrayList this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } @@ -825,7 +825,7 @@ public int addAllAbsent(Collection c) { * Removes all of the elements from this list. * The list will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable CopyOnWriteArrayList this) { + public void clear(@GuardSatisfied @CanShrink CopyOnWriteArrayList this) { synchronized (lock) { setArray(new Object[0]); } @@ -918,7 +918,7 @@ public void forEach(Consumer action) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable CopyOnWriteArrayList this, Predicate filter) { + public boolean removeIf(@CanShrink CopyOnWriteArrayList this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } diff --git a/src/java.base/share/classes/java/util/concurrent/DelayQueue.java b/src/java.base/share/classes/java/util/concurrent/DelayQueue.java index 493fa19b734..aa60ebc1f2b 100644 --- a/src/java.base/share/classes/java/util/concurrent/DelayQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/DelayQueue.java @@ -51,7 +51,7 @@ import org.checkerframework.checker.nonempty.qual.PolyNonEmpty; import org.checkerframework.checker.index.qual.PolyGrowShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import java.util.AbstractQueue; import java.util.Collection; import java.util.Iterator; @@ -228,7 +228,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) { * @return the expired head of this queue, or {@code null} if this * queue has no elements with an expired delay */ - public @Nullable E poll(@GuardSatisfied @Shrinkable DelayQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink DelayQueue this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -249,7 +249,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) { * @return the expired head of this queue * @throws InterruptedException {@inheritDoc} */ - public E take(@GuardSatisfied @Shrinkable DelayQueue this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink DelayQueue this) throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { @@ -294,7 +294,7 @@ public E take(@GuardSatisfied @Shrinkable DelayQueue this) throws Interrupted * an expired delay becomes available * @throws InterruptedException {@inheritDoc} */ - public @Nullable E poll(@GuardSatisfied @Shrinkable DelayQueue this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink DelayQueue this, long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); @@ -385,7 +385,7 @@ public int size() { * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable DelayQueue this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink DelayQueue this, Collection c) { return drainTo(c, Integer.MAX_VALUE); } @@ -395,7 +395,7 @@ public int drainTo(@GuardSatisfied @Shrinkable DelayQueue this, Collection this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink DelayQueue this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -425,7 +425,7 @@ public int drainTo(@GuardSatisfied @Shrinkable DelayQueue this, Collection this) { + public void clear(@GuardSatisfied @CanShrink DelayQueue this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -519,7 +519,7 @@ public int remainingCapacity() { * Removes a single instance of the specified element from this * queue, if it is present, whether or not it has expired. */ - public boolean remove(@Shrinkable DelayQueue this, @UnknownSignedness Object o) { + public boolean remove(@CanShrink DelayQueue this, @UnknownSignedness Object o) { final ReentrantLock lock = this.lock; lock.lock(); try { diff --git a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java index c4479427497..30890f666bb 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -260,7 +260,7 @@ private boolean linkLast(Node node) { /** * Removes and returns first element, or null if empty. */ - private E unlinkFirst(@Shrinkable LinkedBlockingDeque this) { + private E unlinkFirst(@CanShrink LinkedBlockingDeque this) { // assert lock.isHeldByCurrentThread(); Node f = first; if (f == null) @@ -282,7 +282,7 @@ private E unlinkFirst(@Shrinkable LinkedBlockingDeque this) { /** * Removes and returns last element, or null if empty. */ - private E unlinkLast(@Shrinkable LinkedBlockingDeque this) { + private E unlinkLast(@CanShrink LinkedBlockingDeque this) { // assert lock.isHeldByCurrentThread(); Node l = last; if (l == null) @@ -304,7 +304,7 @@ private E unlinkLast(@Shrinkable LinkedBlockingDeque this) { /** * Unlinks x. */ - void unlink(@Shrinkable LinkedBlockingDeque this, Node x) { + void unlink(@CanShrink LinkedBlockingDeque this, Node x) { // assert lock.isHeldByCurrentThread(); // assert x.item != null; Node p = x.prev; @@ -457,7 +457,7 @@ public boolean offerLast(E e, long timeout, TimeUnit unit) /** * @throws NoSuchElementException {@inheritDoc} */ - public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque this) { + public E removeFirst(@GuardSatisfied @NonEmpty @CanShrink LinkedBlockingDeque this) { E x = pollFirst(); if (x == null) throw new NoSuchElementException(); return x; @@ -466,13 +466,13 @@ public E removeFirst(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque this) { + public E removeLast(@GuardSatisfied @NonEmpty @CanShrink LinkedBlockingDeque this) { E x = pollLast(); if (x == null) throw new NoSuchElementException(); return x; } - public @Nullable E pollFirst(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) { + public @Nullable E pollFirst(@GuardSatisfied @CanShrink LinkedBlockingDeque this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -482,7 +482,7 @@ public E removeLast(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque } } - public @Nullable E pollLast(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) { + public @Nullable E pollLast(@GuardSatisfied @CanShrink LinkedBlockingDeque this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -492,7 +492,7 @@ public E removeLast(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque } } - public E takeFirst(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) throws InterruptedException { + public E takeFirst(@GuardSatisfied @CanShrink LinkedBlockingDeque this) throws InterruptedException { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -505,7 +505,7 @@ public E takeFirst(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) thro } } - public E takeLast(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) throws InterruptedException { + public E takeLast(@GuardSatisfied @CanShrink LinkedBlockingDeque this) throws InterruptedException { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -518,7 +518,7 @@ public E takeLast(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) throw } } - public @Nullable E pollFirst(@GuardSatisfied @Shrinkable LinkedBlockingDeque this, long timeout, TimeUnit unit) + public @Nullable E pollFirst(@GuardSatisfied @CanShrink LinkedBlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; @@ -536,7 +536,7 @@ public E takeLast(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) throw } } - public @Nullable E pollLast(@GuardSatisfied @Shrinkable LinkedBlockingDeque this, long timeout, TimeUnit unit) + public @Nullable E pollLast(@GuardSatisfied @CanShrink LinkedBlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; @@ -594,7 +594,7 @@ public E getLast(@NonEmpty LinkedBlockingDeque this) { } } - public boolean removeFirstOccurrence(@Shrinkable LinkedBlockingDeque this, Object o) { + public boolean removeFirstOccurrence(@CanShrink LinkedBlockingDeque this, Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; lock.lock(); @@ -611,7 +611,7 @@ public boolean removeFirstOccurrence(@Shrinkable LinkedBlockingDeque this, Ob } } - public boolean removeLastOccurrence(@Shrinkable LinkedBlockingDeque this, Object o) { + public boolean removeLastOccurrence(@CanShrink LinkedBlockingDeque this, Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; lock.lock(); @@ -680,19 +680,19 @@ public boolean offer(E e, long timeout, TimeUnit unit) * @return the head of the queue represented by this deque * @throws NoSuchElementException if this deque is empty */ - public E remove(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque this) { + public E remove(@GuardSatisfied @NonEmpty @CanShrink LinkedBlockingDeque this) { return removeFirst(); } - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedBlockingDeque this) { return pollFirst(); } - public E take(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink LinkedBlockingDeque this) throws InterruptedException { return takeFirst(); } - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedBlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedBlockingDeque this, long timeout, TimeUnit unit) throws InterruptedException { return pollFirst(timeout, unit); } @@ -742,7 +742,7 @@ public int remainingCapacity() { * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable LinkedBlockingDeque this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink LinkedBlockingDeque this, Collection c) { return drainTo(c, Integer.MAX_VALUE); } @@ -752,7 +752,7 @@ public int drainTo(@GuardSatisfied @Shrinkable LinkedBlockingDeque this, Coll * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable LinkedBlockingDeque this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink LinkedBlockingDeque this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -785,7 +785,7 @@ public void push(E e) { /** * @throws NoSuchElementException {@inheritDoc} */ - public E pop(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque this) { + public E pop(@GuardSatisfied @NonEmpty @CanShrink LinkedBlockingDeque this) { return removeFirst(); } @@ -805,7 +805,7 @@ public E pop(@GuardSatisfied @NonEmpty @Shrinkable LinkedBlockingDeque this) * @param o element to be removed from this deque, if present * @return {@code true} if this deque changed as a result of the call */ - public boolean remove(@Shrinkable LinkedBlockingDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink LinkedBlockingDeque this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { return removeFirstOccurrence(o); } @@ -1000,7 +1000,7 @@ public String toString() { * Atomically removes all of the elements from this deque. * The deque will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable LinkedBlockingDeque this) { + public void clear(@GuardSatisfied @CanShrink LinkedBlockingDeque this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -1355,7 +1355,7 @@ void forEachFrom(Consumer action, Node p) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable LinkedBlockingDeque this, Predicate filter) { + public boolean removeIf(@CanShrink LinkedBlockingDeque this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1363,7 +1363,7 @@ public boolean removeIf(@Shrinkable LinkedBlockingDeque this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink LinkedBlockingDeque this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1371,7 +1371,7 @@ public boolean removeAll(@Shrinkable LinkedBlockingDeque this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink LinkedBlockingDeque this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java index c260d22481a..cb784fab495 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; import org.checkerframework.checker.nonempty.qual.NonEmpty; @@ -440,7 +440,7 @@ public boolean offer(E e) { return true; } - public E take(@GuardSatisfied @Shrinkable LinkedBlockingQueue this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink LinkedBlockingQueue this) throws InterruptedException { final E x; final int c; final AtomicInteger count = this.count; @@ -462,7 +462,7 @@ public E take(@GuardSatisfied @Shrinkable LinkedBlockingQueue this) throws In return x; } - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedBlockingQueue this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedBlockingQueue this, long timeout, TimeUnit unit) throws InterruptedException { final E x; final int c; long nanos = unit.toNanos(timeout); @@ -487,7 +487,7 @@ public E take(@GuardSatisfied @Shrinkable LinkedBlockingQueue this) throws In return x; } - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedBlockingQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedBlockingQueue this) { final AtomicInteger count = this.count; if (count.get() == 0) return null; @@ -551,7 +551,7 @@ void unlink(Node p, Node pred) { * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ - public boolean remove(@Shrinkable LinkedBlockingQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink LinkedBlockingQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o == null) return false; fullyLock(); try { @@ -682,7 +682,7 @@ public String toString() { * Atomically removes all of the elements from this queue. * The queue will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable LinkedBlockingQueue this) { + public void clear(@GuardSatisfied @CanShrink LinkedBlockingQueue this) { fullyLock(); try { for (Node p, h = head; (p = h.next) != null; h = p) { @@ -704,7 +704,7 @@ public void clear(@GuardSatisfied @Shrinkable LinkedBlockingQueue this) { * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable LinkedBlockingQueue this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink LinkedBlockingQueue this, Collection c) { return drainTo(c, Integer.MAX_VALUE); } @@ -714,7 +714,7 @@ public int drainTo(@GuardSatisfied @Shrinkable LinkedBlockingQueue this, Coll * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable LinkedBlockingQueue this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink LinkedBlockingQueue this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -1038,7 +1038,7 @@ void forEachFrom(Consumer action, Node p) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable LinkedBlockingQueue this, Predicate filter) { + public boolean removeIf(@CanShrink LinkedBlockingQueue this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1046,7 +1046,7 @@ public boolean removeIf(@Shrinkable LinkedBlockingQueue this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink LinkedBlockingQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1054,7 +1054,7 @@ public boolean removeAll(@Shrinkable LinkedBlockingQueue this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink LinkedBlockingQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java index be770c7f155..55ca7b7bfe5 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -1256,7 +1256,7 @@ public boolean add(E e) { * * @throws NullPointerException if the specified element is null */ - public boolean tryTransfer(@GuardSatisfied @Shrinkable LinkedTransferQueue this, E e) { + public boolean tryTransfer(@GuardSatisfied @CanShrink LinkedTransferQueue this, E e) { return xfer(e, true, NOW, 0L) == null; } @@ -1271,7 +1271,7 @@ public boolean tryTransfer(@GuardSatisfied @Shrinkable LinkedTransferQueue th * * @throws NullPointerException if the specified element is null */ - public void transfer(@GuardSatisfied @Shrinkable LinkedTransferQueue this, E e) throws InterruptedException { + public void transfer(@GuardSatisfied @CanShrink LinkedTransferQueue this, E e) throws InterruptedException { if (xfer(e, true, SYNC, 0L) != null) { Thread.interrupted(); // failure possible only due to interrupt throw new InterruptedException(); @@ -1292,7 +1292,7 @@ public void transfer(@GuardSatisfied @Shrinkable LinkedTransferQueue this, E * * @throws NullPointerException if the specified element is null */ - public boolean tryTransfer(@GuardSatisfied @Shrinkable LinkedTransferQueue this, E e, long timeout, TimeUnit unit) + public boolean tryTransfer(@GuardSatisfied @CanShrink LinkedTransferQueue this, E e, long timeout, TimeUnit unit) throws InterruptedException { if (xfer(e, true, TIMED, unit.toNanos(timeout)) == null) return true; @@ -1301,7 +1301,7 @@ public boolean tryTransfer(@GuardSatisfied @Shrinkable LinkedTransferQueue th throw new InterruptedException(); } - public E take(@GuardSatisfied @Shrinkable LinkedTransferQueue this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink LinkedTransferQueue this) throws InterruptedException { E e = xfer(null, false, SYNC, 0L); if (e != null) return e; @@ -1309,14 +1309,14 @@ public E take(@GuardSatisfied @Shrinkable LinkedTransferQueue this) throws In throw new InterruptedException(); } - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedTransferQueue this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedTransferQueue this, long timeout, TimeUnit unit) throws InterruptedException { E e = xfer(null, false, TIMED, unit.toNanos(timeout)); if (e != null || !Thread.interrupted()) return e; throw new InterruptedException(); } - public @Nullable E poll(@GuardSatisfied @Shrinkable LinkedTransferQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink LinkedTransferQueue this) { return xfer(null, false, NOW, 0L); } @@ -1324,7 +1324,7 @@ public E take(@GuardSatisfied @Shrinkable LinkedTransferQueue this) throws In * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable LinkedTransferQueue this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink LinkedTransferQueue this, Collection c) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -1338,7 +1338,7 @@ public int drainTo(@GuardSatisfied @Shrinkable LinkedTransferQueue this, Coll * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable LinkedTransferQueue this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink LinkedTransferQueue this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -1441,7 +1441,7 @@ public int getWaitingConsumerCount() { * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ - public boolean remove(@Shrinkable LinkedTransferQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink LinkedTransferQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { if (o == null) return false; restartFromHead: for (;;) { for (Node p = head, pred = null; p != null; ) { @@ -1561,7 +1561,7 @@ private void readObject(java.io.ObjectInputStream s) /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable LinkedTransferQueue this, Predicate filter) { + public boolean removeIf(@CanShrink LinkedTransferQueue this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1569,7 +1569,7 @@ public boolean removeIf(@Shrinkable LinkedTransferQueue this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink LinkedTransferQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1577,12 +1577,12 @@ public boolean removeAll(@Shrinkable LinkedTransferQueue this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink LinkedTransferQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } - public void clear(@GuardSatisfied @Shrinkable LinkedTransferQueue this) { + public void clear(@GuardSatisfied @CanShrink LinkedTransferQueue this) { bulkRemove(e -> true); } diff --git a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java index 93fa3b5eb85..c37d447604e 100644 --- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -36,7 +36,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmpty; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; @@ -533,7 +533,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) { return offer(e); // never need to block } - public @Nullable E poll(@GuardSatisfied @Shrinkable PriorityBlockingQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink PriorityBlockingQueue this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -543,7 +543,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) { } } - public E take(@GuardSatisfied @Shrinkable PriorityBlockingQueue this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink PriorityBlockingQueue this) throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); E result; @@ -556,7 +556,7 @@ public E take(@GuardSatisfied @Shrinkable PriorityBlockingQueue this) throws return result; } - public @Nullable E poll(@GuardSatisfied @Shrinkable PriorityBlockingQueue this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink PriorityBlockingQueue this, long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); @@ -661,7 +661,7 @@ private void removeAt(int i) { * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ - public boolean remove(@Shrinkable PriorityBlockingQueue this, @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink PriorityBlockingQueue this, @Nullable @UnknownSignedness Object o) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -726,7 +726,7 @@ public String toString() { * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable PriorityBlockingQueue this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink PriorityBlockingQueue this, Collection c) { return drainTo(c, Integer.MAX_VALUE); } @@ -736,7 +736,7 @@ public int drainTo(@GuardSatisfied @Shrinkable PriorityBlockingQueue this, Co * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable PriorityBlockingQueue this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink PriorityBlockingQueue this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -760,7 +760,7 @@ public int drainTo(@GuardSatisfied @Shrinkable PriorityBlockingQueue this, Co * Atomically removes all of the elements from this queue. * The queue will be empty after this call returns. */ - public void clear(@GuardSatisfied @Shrinkable PriorityBlockingQueue this) { + public void clear(@GuardSatisfied @CanShrink PriorityBlockingQueue this) { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -1031,7 +1031,7 @@ public Spliterator spliterator() { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeIf(@Shrinkable PriorityBlockingQueue this, Predicate filter) { + public boolean removeIf(@CanShrink PriorityBlockingQueue this, Predicate filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } @@ -1039,7 +1039,7 @@ public boolean removeIf(@Shrinkable PriorityBlockingQueue this, Predicate this, Collection c) { + public boolean removeAll(@CanShrink PriorityBlockingQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1047,7 +1047,7 @@ public boolean removeAll(@Shrinkable PriorityBlockingQueue this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink PriorityBlockingQueue this, Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java b/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java index 3c1a35a93bf..076a70f4746 100644 --- a/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java @@ -37,7 +37,7 @@ package java.util.concurrent; import org.checkerframework.checker.index.qual.PolyGrowShrink; -import org.checkerframework.checker.index.qual.Shrinkable; +import org.checkerframework.checker.index.qual.CanShrink; import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; import org.checkerframework.checker.nonempty.qual.PolyNonEmpty; @@ -897,7 +897,7 @@ public boolean offer(E e) { * @return the head of this queue * @throws InterruptedException {@inheritDoc} */ - public E take(@GuardSatisfied @Shrinkable SynchronousQueue this) throws InterruptedException { + public E take(@GuardSatisfied @CanShrink SynchronousQueue this) throws InterruptedException { E e = transferer.transfer(null, false, 0); if (e != null) return e; @@ -914,7 +914,7 @@ public E take(@GuardSatisfied @Shrinkable SynchronousQueue this) throws Inter * specified waiting time elapses before an element is present * @throws InterruptedException {@inheritDoc} */ - public @Nullable E poll(@GuardSatisfied @Shrinkable SynchronousQueue this, long timeout, TimeUnit unit) throws InterruptedException { + public @Nullable E poll(@GuardSatisfied @CanShrink SynchronousQueue this, long timeout, TimeUnit unit) throws InterruptedException { E e = transferer.transfer(null, true, unit.toNanos(timeout)); if (e != null || !Thread.interrupted()) return e; @@ -928,7 +928,7 @@ public E take(@GuardSatisfied @Shrinkable SynchronousQueue this) throws Inter * @return the head of this queue, or {@code null} if no * element is available */ - public @Nullable E poll(@GuardSatisfied @Shrinkable SynchronousQueue this) { + public @Nullable E poll(@GuardSatisfied @CanShrink SynchronousQueue this) { return transferer.transfer(null, true, 0); } @@ -969,7 +969,7 @@ public int remainingCapacity() { * Does nothing. * A {@code SynchronousQueue} has no internal capacity. */ - public void clear(@GuardSatisfied @Shrinkable SynchronousQueue this) { + public void clear(@GuardSatisfied @CanShrink SynchronousQueue this) { } /** @@ -992,7 +992,7 @@ public boolean contains(@GuardSatisfied @Nullable @UnknownSignedness Object o) { * @param o the element to remove * @return {@code false} */ - public boolean remove(@Shrinkable SynchronousQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { + public boolean remove(@CanShrink SynchronousQueue this, @GuardSatisfied @Nullable @UnknownSignedness Object o) { return false; } @@ -1015,7 +1015,7 @@ public boolean containsAll(Collection c) { * @param c the collection * @return {@code false} */ - public boolean removeAll(@Shrinkable SynchronousQueue this, Collection c) { + public boolean removeAll(@CanShrink SynchronousQueue this, Collection c) { return false; } @@ -1026,7 +1026,7 @@ public boolean removeAll(@Shrinkable SynchronousQueue this, Collection this, Collection c) { + public boolean retainAll(@GuardSatisfied @CanShrink SynchronousQueue this, Collection c) { return false; } @@ -1103,7 +1103,7 @@ public String toString() { * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable SynchronousQueue this, Collection c) { + public int drainTo(@GuardSatisfied @CanShrink SynchronousQueue this, Collection c) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); @@ -1119,7 +1119,7 @@ public int drainTo(@GuardSatisfied @Shrinkable SynchronousQueue this, Collect * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ - public int drainTo(@GuardSatisfied @Shrinkable SynchronousQueue this, Collection c, int maxElements) { + public int drainTo(@GuardSatisfied @CanShrink SynchronousQueue this, Collection c, int maxElements) { Objects.requireNonNull(c); if (c == this) throw new IllegalArgumentException(); diff --git a/src/java.base/share/classes/org/checkerframework/checker/index/qual/BottomGrowShrink.java b/src/java.base/share/classes/org/checkerframework/checker/index/qual/BottomGrowShrink.java index 95f336c5e09..21f40681441 100644 --- a/src/java.base/share/classes/org/checkerframework/checker/index/qual/BottomGrowShrink.java +++ b/src/java.base/share/classes/org/checkerframework/checker/index/qual/BottomGrowShrink.java @@ -18,5 +18,5 @@ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) -@SubtypeOf({GrowOnly.class, UncheckedShrinkable.class}) +@SubtypeOf({GrowOnly.class, UncheckedCanShrink.class}) public @interface BottomGrowShrink {} diff --git a/src/java.base/share/classes/org/checkerframework/checker/index/qual/Shrinkable.java b/src/java.base/share/classes/org/checkerframework/checker/index/qual/CanShrink.java similarity index 81% rename from src/java.base/share/classes/org/checkerframework/checker/index/qual/Shrinkable.java rename to src/java.base/share/classes/org/checkerframework/checker/index/qual/CanShrink.java index 44aa707b816..be645038898 100644 --- a/src/java.base/share/classes/org/checkerframework/checker/index/qual/Shrinkable.java +++ b/src/java.base/share/classes/org/checkerframework/checker/index/qual/CanShrink.java @@ -9,7 +9,7 @@ import java.lang.annotation.Target; /** - * An expression of type {@code @Shrinkable} may be used to remove elements, e.g., by calling {@code + * An expression of type {@code @CanShrink} may be used to remove elements, e.g., by calling {@code * remove()} or {@code clear()} on it. */ // Reinstate when lists are supported: @@ -18,4 +18,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @SubtypeOf({UnshrinkableRef.class}) -public @interface Shrinkable {} +public @interface CanShrink {} diff --git a/src/java.base/share/classes/org/checkerframework/checker/index/qual/UncheckedShrinkable.java b/src/java.base/share/classes/org/checkerframework/checker/index/qual/UncheckedCanShrink.java similarity index 73% rename from src/java.base/share/classes/org/checkerframework/checker/index/qual/UncheckedShrinkable.java rename to src/java.base/share/classes/org/checkerframework/checker/index/qual/UncheckedCanShrink.java index 559cfc410dc..91ca811bdd7 100644 --- a/src/java.base/share/classes/org/checkerframework/checker/index/qual/UncheckedShrinkable.java +++ b/src/java.base/share/classes/org/checkerframework/checker/index/qual/UncheckedCanShrink.java @@ -9,13 +9,13 @@ import java.lang.annotation.Target; /** - * An expression of type {@code @UncheckedShrinkable} may be used to remove elements, e.g., by + * An expression of type {@code @UncheckedCanShrink} may be used to remove elements, e.g., by * calling {@code remove()} or {@code clear()} on it. * *

The Index Checker does not issue warnings about possible {@code IndexOutOfBoundsException}s - * when the collection has type {@code UncheckedShrinkable}. + * when the collection has type {@code UncheckedCanShrink}. * - *

Thus, {@code @UncheckedShrinkable} is combination of {@code @}{@link Shrinkable} and a warning + *

Thus, {@code @UncheckedCanShrink} is a combination of {@code @}{@link CanShrink} and a warning * suppression. It is particularly useful when first annotating a codebase, to temporarily suppress * some warnings while focusing on others. * @@ -26,5 +26,5 @@ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) -@SubtypeOf({Shrinkable.class}) -public @interface UncheckedShrinkable {} +@SubtypeOf({CanShrink.class}) +public @interface UncheckedCanShrink {} diff --git a/src/java.base/share/classes/org/checkerframework/checker/units/qual/Prefix.java b/src/java.base/share/classes/org/checkerframework/checker/units/qual/Prefix.java index 3aa2428f32b..6273e69675a 100644 --- a/src/java.base/share/classes/org/checkerframework/checker/units/qual/Prefix.java +++ b/src/java.base/share/classes/org/checkerframework/checker/units/qual/Prefix.java @@ -4,7 +4,7 @@ * SI prefixes. * *

From http://en.wikipedia.org/wiki/SI_prefix: + * href="https://en.wikipedia.org/wiki/SI_prefix">https://en.wikipedia.org/wiki/SI_prefix: * *

  * yotta   Y   1000^8     10^24    1000000000000000000000000   Septillion      Quadrillion     1991