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 a93e77bd76e..d6796d57c8a 100644 --- a/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java @@ -1481,7 +1481,7 @@ public boolean removeIf(Predicate filter) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1489,7 +1489,7 @@ public boolean removeAll(Collection c) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean retainAll(Collection c) { + public boolean retainAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } 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 39d2b7ec60c..d9e3bd51546 100644 --- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -40,6 +40,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull; import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; +import org.checkerframework.framework.qual.AnnotatedFor; import java.lang.invoke.VarHandle; import java.lang.reflect.Field; @@ -97,6 +98,7 @@ * @author Doug Lea * @param the type of elements held in this list */ +@AnnotatedFor({"nullness"}) public class CopyOnWriteArrayList implements List, RandomAccess, Cloneable, java.io.Serializable { private static final long serialVersionUID = 8673264195747942595L; @@ -263,7 +265,7 @@ public int indexOf(@Nullable Object o) { * {@code -1} if the element is not found. * @throws IndexOutOfBoundsException if the specified index is negative */ - public int indexOf(E e, int index) { + public int indexOf(@Nullable E e, int index) { Object[] es = getArray(); return indexOfRange(e, es, index, es.length); } @@ -292,7 +294,7 @@ public int lastIndexOf(@Nullable Object o) { * @throws IndexOutOfBoundsException if the specified index is greater * than or equal to the current size of this list */ - public int lastIndexOf(E e, int index) { + public int lastIndexOf(@Nullable E e, int index) { Object[] es = getArray(); return lastIndexOfRange(e, es, 0, index + 1); } @@ -659,7 +661,7 @@ public boolean containsAll(Collection c) { * or if the specified collection is null * @see #remove(Object) */ - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -680,7 +682,7 @@ public boolean removeAll(Collection c) { * or if the specified collection is null * @see #remove(Object) */ - public boolean retainAll(Collection c) { + public boolean retainAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } diff --git a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java index 620cc0e9b88..c9431cf78e0 100644 --- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java +++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java @@ -41,6 +41,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull; import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; +import org.checkerframework.framework.qual.AnnotatedFor; import java.util.AbstractSet; import java.util.Collection; @@ -102,6 +103,7 @@ * @author Doug Lea * @param the type of elements held in this set */ +@AnnotatedFor({"nullness"}) public class CopyOnWriteArraySet extends AbstractSet implements java.io.Serializable { private static final long serialVersionUID = 5457747651344034263L; @@ -356,7 +358,7 @@ public boolean addAll(Collection c) { * or if the specified collection is null * @see #remove(Object) */ - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { return al.removeAll(c); } @@ -379,7 +381,7 @@ public boolean removeAll(Collection c) { * or if the specified collection is null * @see #remove(Object) */ - public boolean retainAll(Collection c) { + public boolean retainAll(Collection c) { return al.retainAll(c); } 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 379d5e9c972..a9f515fb565 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java @@ -581,7 +581,7 @@ public E getLast() { } } - public boolean removeFirstOccurrence(Object o) { + public boolean removeFirstOccurrence(@Nullable Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; lock.lock(); @@ -598,7 +598,7 @@ public boolean removeFirstOccurrence(Object o) { } } - public boolean removeLastOccurrence(Object o) { + public boolean removeLastOccurrence(@Nullable Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; lock.lock(); @@ -790,7 +790,7 @@ public E pop() { * @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(Object o) { + public boolean remove(@Nullable Object o) { return removeFirstOccurrence(o); } @@ -1344,7 +1344,7 @@ public boolean removeIf(Predicate filter) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1352,7 +1352,7 @@ public boolean removeAll(Collection c) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean retainAll(Collection c) { + public boolean retainAll(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 445c393301f..f51a5a4f5c2 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java @@ -1031,7 +1031,7 @@ public boolean removeIf(Predicate filter) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1039,7 +1039,7 @@ public boolean removeAll(Collection c) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean retainAll(Collection c) { + public boolean retainAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } 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 6e6c2e677d6..ecddf7eab0d 100644 --- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -1036,7 +1036,7 @@ public boolean removeIf(Predicate filter) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } @@ -1044,7 +1044,7 @@ public boolean removeAll(Collection c) { /** * @throws NullPointerException {@inheritDoc} */ - public boolean retainAll(Collection c) { + public boolean retainAll(Collection c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); }