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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.PolyNull;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.lang.ref.WeakReference;
import java.util.AbstractQueue;
Expand Down Expand Up @@ -88,7 +89,8 @@
* @author Doug Lea
* @param <E> the type of elements held in this queue
*/
public class ArrayBlockingQueue<E> extends AbstractQueue<E>
@AnnotatedFor({"nullness"})
public class ArrayBlockingQueue<E extends Object> extends AbstractQueue<E>
implements BlockingQueue<E>, java.io.Serializable {

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.PolyNull;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.util.AbstractQueue;
import java.util.Collection;
Expand Down Expand Up @@ -80,7 +81,8 @@
* @author Doug Lea
* @param <E> the type of elements held in this deque
*/
public class LinkedBlockingDeque<E>
@AnnotatedFor({"nullness"})
public class LinkedBlockingDeque<E extends Object>
extends AbstractQueue<E>
implements BlockingDeque<E>, java.io.Serializable {

Expand Down Expand Up @@ -459,7 +461,7 @@ public E removeLast() {
return x;
}

public E pollFirst() {
public @Nullable E pollFirst() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Expand All @@ -469,7 +471,7 @@ public E pollFirst() {
}
}

public E pollLast() {
public @Nullable E pollLast() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Expand Down Expand Up @@ -505,7 +507,7 @@ public E takeLast() throws InterruptedException {
}
}

public E pollFirst(long timeout, TimeUnit unit)
public @Nullable E pollFirst(long timeout, TimeUnit unit)
throws InterruptedException {
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
Expand All @@ -523,7 +525,7 @@ public E pollFirst(long timeout, TimeUnit unit)
}
}

public E pollLast(long timeout, TimeUnit unit)
public @Nullable E pollLast(long timeout, TimeUnit unit)
throws InterruptedException {
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
Expand Down Expand Up @@ -559,7 +561,7 @@ public E getLast() {
return x;
}

public E peekFirst() {
public @Nullable E peekFirst() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Expand All @@ -569,7 +571,7 @@ public E peekFirst() {
}
}

public E peekLast() {
public @Nullable E peekLast() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Expand Down Expand Up @@ -668,15 +670,15 @@ public E remove() {
return removeFirst();
}

public E poll() {
public @Nullable E poll() {
return pollFirst();
}

public E take() throws InterruptedException {
return takeFirst();
}

public E poll(long timeout, TimeUnit unit) throws InterruptedException {
public @Nullable E poll(long timeout, TimeUnit unit) throws InterruptedException {
return pollFirst(timeout, unit);
}

Expand All @@ -694,7 +696,7 @@ public E element() {
return getFirst();
}

public E peek() {
public @Nullable E peek() {
return peekFirst();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.PolyNull;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.util.AbstractQueue;
import java.util.Collection;
Expand Down Expand Up @@ -83,7 +84,8 @@
* @author Doug Lea
* @param <E> the type of elements held in this queue
*/
public class LinkedBlockingQueue<E> extends AbstractQueue<E>
@AnnotatedFor({"nullness"})
public class LinkedBlockingQueue<E extends Object> extends AbstractQueue<E>
implements BlockingQueue<E>, java.io.Serializable {
private static final long serialVersionUID = -6903933977591709194L;

Expand Down Expand Up @@ -450,7 +452,7 @@ public E take() throws InterruptedException {
return x;
}

public E poll(long timeout, TimeUnit unit) throws InterruptedException {
public @Nullable E poll(long timeout, TimeUnit unit) throws InterruptedException {
final E x;
final int c;
long nanos = unit.toNanos(timeout);
Expand All @@ -475,7 +477,7 @@ public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return x;
}

public E poll() {
public @Nullable E poll() {
final AtomicInteger count = this.count;
if (count.get() == 0)
return null;
Expand All @@ -498,7 +500,7 @@ public E poll() {
return x;
}

public E peek() {
public @Nullable E peek() {
final AtomicInteger count = this.count;
if (count.get() == 0)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.PolyNull;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
Expand Down Expand Up @@ -115,8 +116,9 @@
* @author Doug Lea
* @param <E> the type of elements held in this queue
*/
@AnnotatedFor({"nullness"})
@SuppressWarnings("unchecked")
public class PriorityBlockingQueue<E> extends AbstractQueue<E>
public class PriorityBlockingQueue<E extends Object> extends AbstractQueue<E>
implements BlockingQueue<E>, java.io.Serializable {
private static final long serialVersionUID = 5595510919245408276L;

Expand Down Expand Up @@ -533,7 +535,7 @@ public boolean offer(E e, long timeout, TimeUnit unit) {
return offer(e); // never need to block
}

public E poll() {
public @Nullable E poll() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Expand All @@ -556,7 +558,7 @@ public E take() throws InterruptedException {
return result;
}

public E poll(long timeout, TimeUnit unit) throws InterruptedException {
public @Nullable E poll(long timeout, TimeUnit unit) throws InterruptedException {
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
Expand All @@ -570,7 +572,7 @@ public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return result;
}

public E peek() {
public @Nullable E peek() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Expand Down