8232230: Suppress warnings on non-serializable non-transient instance fields in java.util.concurrent
Reviewed-by: martin
--- a/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java Wed Oct 16 16:55:52 2019 -0700
@@ -100,6 +100,7 @@
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 @@
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;
/**
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java Wed Oct 16 16:55:52 2019 -0700
@@ -4584,6 +4584,7 @@
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);
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Wed Oct 16 16:55:52 2019 -0700
@@ -334,6 +334,7 @@
* nested classes.)
* @serial
*/
+ @SuppressWarnings("serial") // Conditionally serializable
final Comparator<? super K> comparator;
/** Lazily initialized topmost index of the skiplist. */
@@ -2375,8 +2376,10 @@
/** 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;
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Wed Oct 16 16:55:52 2019 -0700
@@ -103,6 +103,7 @@
* 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;
/**
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java Wed Oct 16 16:55:52 2019 -0700
@@ -1374,7 +1374,9 @@
*/
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 @@
*/
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 @@
* 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 @@
*/
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();
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java Wed Oct 16 16:55:52 2019 -0700
@@ -159,9 +159,11 @@
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();
/**
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java Wed Oct 16 16:55:52 2019 -0700
@@ -156,12 +156,14 @@
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();
/**
--- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java Wed Oct 16 16:55:52 2019 -0700
@@ -173,6 +173,7 @@
/**
* Condition for blocking when empty.
*/
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = lock.newCondition();
/**
--- a/src/java.base/share/classes/java/util/concurrent/RecursiveTask.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/RecursiveTask.java Wed Oct 16 16:55:52 2019 -0700
@@ -71,6 +71,7 @@
/**
* The result of the computation.
*/
+ @SuppressWarnings("serial") // Conditionally serializable
V result;
/**
--- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Wed Oct 16 16:55:52 2019 -0700
@@ -604,8 +604,10 @@
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;
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java Wed Oct 16 16:55:52 2019 -0700
@@ -60,6 +60,7 @@
}
}
+ @SuppressWarnings("serial") // Conditionally serializable
private volatile V value;
/**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Wed Oct 16 16:55:52 2019 -0700
@@ -55,6 +55,7 @@
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[]
/**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java Wed Oct 16 16:55:52 2019 -0700
@@ -84,6 +84,7 @@
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 @@
* The function used for updates.
* @serial
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final DoubleBinaryOperator function;
/**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java Thu Oct 17 07:31:35 2019 +0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java Wed Oct 16 16:55:52 2019 -0700
@@ -82,6 +82,7 @@
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 @@
* The function used for updates.
* @serial
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final LongBinaryOperator function;
/**