8232230: Suppress warnings on non-serializable non-transient instance fields in java.util.concurrent

Reviewed-by: martin
This commit is contained in:
Joe Darcy 2019-10-16 16:55:52 -07:00
parent 49883054db
commit 98c9f8bdc7
14 changed files with 28 additions and 0 deletions

View File

@ -100,6 +100,7 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
private static final long serialVersionUID = -817911632652898426L;
/** The queued items */
@SuppressWarnings("serial") // Conditionally serializable
final Object[] items;
/** items index for next take, poll, peek or remove */
@ -120,9 +121,11 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
final ReentrantLock lock;
/** Condition for waiting takes */
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty;
/** Condition for waiting puts */
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notFull;
/**

View File

@ -4584,6 +4584,7 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
public static class KeySetView<K,V> extends CollectionView<K,V,K>
implements Set<K>, java.io.Serializable {
private static final long serialVersionUID = 7249069246763182397L;
@SuppressWarnings("serial") // Conditionally serializable
private final V value;
KeySetView(ConcurrentHashMap<K,V> map, V value) { // non-public
super(map);

View File

@ -334,6 +334,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
* nested classes.)
* @serial
*/
@SuppressWarnings("serial") // Conditionally serializable
final Comparator<? super K> comparator;
/** Lazily initialized topmost index of the skiplist. */
@ -2375,8 +2376,10 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
/** Underlying map */
final ConcurrentSkipListMap<K,V> m;
/** lower bound key, or null if from start */
@SuppressWarnings("serial") // Conditionally serializable
private final K lo;
/** upper bound key, or null if to end */
@SuppressWarnings("serial") // Conditionally serializable
private final K hi;
/** inclusion flag for lo */
private final boolean loInclusive;

View File

@ -103,6 +103,7 @@ public class ConcurrentSkipListSet<E>
* element. This field is declared final for the sake of thread
* safety, which entails some ugliness in clone().
*/
@SuppressWarnings("serial") // Conditionally serializable
private final ConcurrentNavigableMap<E,Object> m;
/**

View File

@ -1374,7 +1374,9 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
*/
static final class AdaptedRunnable<T> extends ForkJoinTask<T>
implements RunnableFuture<T> {
@SuppressWarnings("serial") // Conditionally serializable
final Runnable runnable;
@SuppressWarnings("serial") // Conditionally serializable
T result;
AdaptedRunnable(Runnable runnable, T result) {
if (runnable == null) throw new NullPointerException();
@ -1396,6 +1398,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
*/
static final class AdaptedRunnableAction extends ForkJoinTask<Void>
implements RunnableFuture<Void> {
@SuppressWarnings("serial") // Conditionally serializable
final Runnable runnable;
AdaptedRunnableAction(Runnable runnable) {
if (runnable == null) throw new NullPointerException();
@ -1415,6 +1418,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* Adapter for Runnables in which failure forces worker exception.
*/
static final class RunnableExecuteAction extends ForkJoinTask<Void> {
@SuppressWarnings("serial") // Conditionally serializable
final Runnable runnable;
RunnableExecuteAction(Runnable runnable) {
if (runnable == null) throw new NullPointerException();
@ -1434,7 +1438,9 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
*/
static final class AdaptedCallable<T> extends ForkJoinTask<T>
implements RunnableFuture<T> {
@SuppressWarnings("serial") // Conditionally serializable
final Callable<? extends T> callable;
@SuppressWarnings("serial") // Conditionally serializable
T result;
AdaptedCallable(Callable<? extends T> callable) {
if (callable == null) throw new NullPointerException();

View File

@ -159,9 +159,11 @@ public class LinkedBlockingDeque<E>
final ReentrantLock lock = new ReentrantLock();
/** Condition for waiting takes */
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = lock.newCondition();
/** Condition for waiting puts */
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notFull = lock.newCondition();
/**

View File

@ -156,12 +156,14 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
private final ReentrantLock takeLock = new ReentrantLock();
/** Wait queue for waiting takes */
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = takeLock.newCondition();
/** Lock held by put, offer, etc */
private final ReentrantLock putLock = new ReentrantLock();
/** Wait queue for waiting puts */
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notFull = putLock.newCondition();
/**

View File

@ -173,6 +173,7 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
/**
* Condition for blocking when empty.
*/
@SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = lock.newCondition();
/**

View File

@ -71,6 +71,7 @@ public abstract class RecursiveTask<V> extends ForkJoinTask<V> {
/**
* The result of the computation.
*/
@SuppressWarnings("serial") // Conditionally serializable
V result;
/**

View File

@ -604,8 +604,10 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
private static final long serialVersionUID = 6138294804551838833L;
/** Thread this worker is running in. Null if factory fails. */
@SuppressWarnings("serial") // Unlikely to be serializable
final Thread thread;
/** Initial task to run. Possibly null. */
@SuppressWarnings("serial") // Not statically typed as Serializable
Runnable firstTask;
/** Per-thread task counter */
volatile long completedTasks;

View File

@ -60,6 +60,7 @@ public class AtomicReference<V> implements java.io.Serializable {
}
}
@SuppressWarnings("serial") // Conditionally serializable
private volatile V value;
/**

View File

@ -55,6 +55,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
private static final long serialVersionUID = -6209656149925076980L;
private static final VarHandle AA
= MethodHandles.arrayElementVarHandle(Object[].class);
@SuppressWarnings("serial") // Conditionally serializable
private final Object[] array; // must have exact type Object[]
/**

View File

@ -84,6 +84,7 @@ import java.util.function.DoubleBinaryOperator;
public class DoubleAccumulator extends Striped64 implements Serializable {
private static final long serialVersionUID = 7249069246863182397L;
@SuppressWarnings("serial") // Not statically typed as Serializable
private final DoubleBinaryOperator function;
private final long identity; // use long representation
@ -245,6 +246,7 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
* The function used for updates.
* @serial
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
private final DoubleBinaryOperator function;
/**

View File

@ -82,6 +82,7 @@ import java.util.function.LongBinaryOperator;
public class LongAccumulator extends Striped64 implements Serializable {
private static final long serialVersionUID = 7249069246863182397L;
@SuppressWarnings("serial") // Not statically typed as Serializable
private final LongBinaryOperator function;
private final long identity;
@ -239,6 +240,7 @@ public class LongAccumulator extends Striped64 implements Serializable {
* The function used for updates.
* @serial
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
private final LongBinaryOperator function;
/**