Skip to content
Permalink
Browse files

8231202: Suppress warnings on non-serializable non-transient instance…

… fields in serializable classes

Reviewed-by: rriggs, chegar
  • Loading branch information
jddarcy committed Oct 9, 2019
1 parent fbb4093 commit 3c9b6d8554bbe371cde9c72ea2e5fae1d91aa68a
@@ -230,6 +230,7 @@
* @serial
* @since 1.7
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
private List<Throwable> suppressedExceptions = SUPPRESSED_SENTINEL;

/** Message for trying to suppress a null exception. */
@@ -76,6 +76,7 @@
private final String implMethodSignature;
private final int implMethodKind;
private final String instantiatedMethodType;
@SuppressWarnings("serial") // Not statically typed as Serializable
private final Object[] capturedArgs;

/**
@@ -308,6 +308,7 @@
* the invocation handler for this proxy instance.
* @serial
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
protected InvocationHandler h;

/**
@@ -641,6 +641,7 @@ public String toString() {
static final class OffsetClock extends Clock implements Serializable {
@java.io.Serial
private static final long serialVersionUID = 2007484719125426256L;
@SuppressWarnings("serial") // Not statically typed as Serializable
private final Clock baseClock;
private final Duration offset;

@@ -692,6 +693,7 @@ public String toString() {
static final class TickClock extends Clock implements Serializable {
@java.io.Serial
private static final long serialVersionUID = 6504659149906368850L;
@SuppressWarnings("serial") // Not statically typed as Serializable
private final Clock baseClock;
private final long tickNanos;

@@ -109,6 +109,7 @@
/**
* The chronology.
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
private final Chronology chrono;
/**
* The number of years.
@@ -607,7 +607,9 @@ private static boolean eq(Object o1, Object o2) {
@java.io.Serial
private static final long serialVersionUID = -8499721149061103585L;

@SuppressWarnings("serial") // Conditionally serializable
private final K key;
@SuppressWarnings("serial") // Conditionally serializable
private V value;

/**
@@ -738,7 +740,9 @@ public String toString() {
@java.io.Serial
private static final long serialVersionUID = 7138329143949025153L;

@SuppressWarnings("serial") // Not statically typed as Serializable
private final K key;
@SuppressWarnings("serial") // Not statically typed as Serializable
private final V value;

/**
@@ -103,10 +103,15 @@ private ArrayPrefixHelpers() {} // non-instantiable
static final int MIN_PARTITION = 16;

static final class CumulateTask<T> extends CountedCompleter<Void> {
@SuppressWarnings("serial") // Not statically typed as Serializable
final T[] array;
@SuppressWarnings("serial") // Not statically typed as Serializable
final BinaryOperator<T> function;
CumulateTask<T> left, right;
T in, out;
@SuppressWarnings("serial") // Not statically typed as Serializable
T in;
@SuppressWarnings("serial") // Not statically typed as Serializable
T out;
final int lo, hi, origin, fence, threshold;

/** Root task constructor */
@@ -257,6 +262,7 @@ else if (par.compareAndSetPendingCount(b, b|state))

static final class LongCumulateTask extends CountedCompleter<Void> {
final long[] array;
@SuppressWarnings("serial") // Not statically typed as Serializable
final LongBinaryOperator function;
LongCumulateTask left, right;
long in, out;
@@ -408,6 +414,7 @@ else if (par.compareAndSetPendingCount(b, b|state))

static final class DoubleCumulateTask extends CountedCompleter<Void> {
final double[] array;
@SuppressWarnings("serial") // Not statically typed as Serializable
final DoubleBinaryOperator function;
DoubleCumulateTask left, right;
double in, out;
@@ -559,6 +566,7 @@ else if (par.compareAndSetPendingCount(b, b|state))

static final class IntCumulateTask extends CountedCompleter<Void> {
final int[] array;
@SuppressWarnings("serial") // Not statically typed as Serializable
final IntBinaryOperator function;
IntCumulateTask left, right;
int in, out;
@@ -4339,6 +4339,7 @@ public static void fill(Object[] a, int fromIndex, int toIndex, Object val) {
{
@java.io.Serial
private static final long serialVersionUID = -2764017481108945198L;
@SuppressWarnings("serial") // Conditionally serializable
private final E[] a;

ArrayList(E[] array) {
@@ -115,8 +115,12 @@ public final void onCompletion(CountedCompleter<?> t) {
static final class Sorter<T> extends CountedCompleter<Void> {
@java.io.Serial
static final long serialVersionUID = 2446542900576103244L;
final T[] a, w;
@SuppressWarnings("serial") // Not statically typed as Serializable
final T[] a;
@SuppressWarnings("serial") // Not statically typed as Serializable
final T[] w;
final int base, size, wbase, gran;
@SuppressWarnings("serial") // Not statically typed as Serializable
Comparator<? super T> comparator;
Sorter(CountedCompleter<?> par, T[] a, T[] w, int base, int size,
int wbase, int gran,
@@ -153,8 +157,13 @@ public final void compute() {
static final class Merger<T> extends CountedCompleter<Void> {
@java.io.Serial
static final long serialVersionUID = 2446542900576103244L;
final T[] a, w; // main and workspace arrays
// main and workspace arrays
@SuppressWarnings("serial") // Not statically typed as Serializable
final T[] a;
@SuppressWarnings("serial") // Not statically typed as Serializable
final T[] w;
final int lbase, lsize, rbase, rsize, wbase, gran;
@SuppressWarnings("serial") // Not statically typed as Serializable
Comparator<? super T> comparator;
Merger(CountedCompleter<?> par, T[] a, T[] w,
int lbase, int lsize, int rbase,
@@ -1024,6 +1024,7 @@ public static int lastIndexOfSubList(List<?> source, List<?> target) {
@java.io.Serial
private static final long serialVersionUID = 1820017752578914078L;

@SuppressWarnings("serial") // Conditionally serializable
final Collection<? extends E> c;

UnmodifiableCollection(Collection<? extends E> c) {
@@ -1164,6 +1165,7 @@ public boolean removeIf(Predicate<? super E> filter) {
implements SortedSet<E>, Serializable {
@java.io.Serial
private static final long serialVersionUID = -4929149591599911165L;
@SuppressWarnings("serial") // Conditionally serializable
private final SortedSet<E> ss;

UnmodifiableSortedSet(SortedSet<E> s) {super(s); ss = s;}
@@ -1244,6 +1246,7 @@ public EmptyNavigableSet() {
/**
* The instance we are protecting.
*/
@SuppressWarnings("serial") // Conditionally serializable
private final NavigableSet<E> ns;

UnmodifiableNavigableSet(NavigableSet<E> s) {super(s); ns = s;}
@@ -1304,6 +1307,7 @@ public EmptyNavigableSet() {
@java.io.Serial
private static final long serialVersionUID = -283967356065247728L;

@SuppressWarnings("serial") // Conditionally serializable
final List<? extends E> list;

UnmodifiableList(List<? extends E> list) {
@@ -1450,6 +1454,7 @@ private Object writeReplace() {
@java.io.Serial
private static final long serialVersionUID = -1034234728574286014L;

@SuppressWarnings("serial") // Conditionally serializable
private final Map<? extends K, ? extends V> m;

UnmodifiableMap(Map<? extends K, ? extends V> m) {
@@ -1809,6 +1814,7 @@ public boolean equals(Object o) {
@java.io.Serial
private static final long serialVersionUID = -8806743815996713206L;

@SuppressWarnings("serial") // Conditionally serializable
private final SortedMap<K, ? extends V> sm;

UnmodifiableSortedMap(SortedMap<K, ? extends V> m) {super(m); sm = m; }
@@ -1886,6 +1892,7 @@ public boolean equals(Object o) {
/**
* The instance we wrap and protect.
*/
@SuppressWarnings("serial") // Conditionally serializable
private final NavigableMap<K, ? extends V> nm;

UnmodifiableNavigableMap(NavigableMap<K, ? extends V> m)
@@ -2017,7 +2024,9 @@ public boolean equals(Object o) {
@java.io.Serial
private static final long serialVersionUID = 3053995032091335093L;

@SuppressWarnings("serial") // Conditionally serializable
final Collection<E> c; // Backing Collection
@SuppressWarnings("serial") // Conditionally serializable
final Object mutex; // Object on which to synchronize

SynchronizedCollection(Collection<E> c) {
@@ -2219,6 +2228,7 @@ public int hashCode() {
@java.io.Serial
private static final long serialVersionUID = 8695801310862127406L;

@SuppressWarnings("serial") // Conditionally serializable
private final SortedSet<E> ss;

SynchronizedSortedSet(SortedSet<E> s) {
@@ -2314,6 +2324,7 @@ public E last() {
@java.io.Serial
private static final long serialVersionUID = -5505529816273629798L;

@SuppressWarnings("serial") // Conditionally serializable
private final NavigableSet<E> ns;

SynchronizedNavigableSet(NavigableSet<E> s) {
@@ -2424,6 +2435,7 @@ public E last() {
@java.io.Serial
private static final long serialVersionUID = -7754090372962971524L;

@SuppressWarnings("serial") // Conditionally serializable
final List<E> list;

SynchronizedList(List<E> list) {
@@ -2591,7 +2603,9 @@ private Object writeReplace() {
@java.io.Serial
private static final long serialVersionUID = 1978198479659022715L;

@SuppressWarnings("serial") // Conditionally serializable
private final Map<K,V> m; // Backing Map
@SuppressWarnings("serial") // Conditionally serializable
final Object mutex; // Object on which to synchronize

SynchronizedMap(Map<K,V> m) {
@@ -2788,6 +2802,7 @@ private void writeObject(ObjectOutputStream s) throws IOException {
@java.io.Serial
private static final long serialVersionUID = -8798146769416483793L;

@SuppressWarnings("serial") // Conditionally serializable
private final SortedMap<K,V> sm;

SynchronizedSortedMap(SortedMap<K,V> m) {
@@ -2891,6 +2906,7 @@ public K lastKey() {
@java.io.Serial
private static final long serialVersionUID = 699392247599746807L;

@SuppressWarnings("serial") // Conditionally serializable
private final NavigableMap<K,V> nm;

SynchronizedNavigableMap(NavigableMap<K,V> m) {
@@ -3070,7 +3086,9 @@ public K higherKey(K key)
@java.io.Serial
private static final long serialVersionUID = 1578914078182001775L;

@SuppressWarnings("serial") // Conditionally serializable
final Collection<E> c;
@SuppressWarnings("serial") // Conditionally serializable
final Class<E> type;

@SuppressWarnings("unchecked")
@@ -3126,6 +3144,7 @@ public void forEachRemaining(Consumer<? super E> action) {

public boolean add(E e) { return c.add(typeCheck(e)); }

@SuppressWarnings("serial") // Conditionally serializable
private E[] zeroLengthElementArray; // Lazily initialized

private E[] zeroLengthElementArray() {
@@ -3219,6 +3238,7 @@ public boolean removeIf(Predicate<? super E> filter) {
{
@java.io.Serial
private static final long serialVersionUID = 1433151992604707767L;
@SuppressWarnings("serial") // Conditionally serializable
final Queue<E> queue;

CheckedQueue(Queue<E> queue, Class<E> elementType) {
@@ -3323,6 +3343,7 @@ public boolean removeIf(Predicate<? super E> filter) {
@java.io.Serial
private static final long serialVersionUID = 1599911165492914959L;

@SuppressWarnings("serial") // Conditionally serializable
private final SortedSet<E> ss;

CheckedSortedSet(SortedSet<E> s, Class<E> type) {
@@ -3387,6 +3408,7 @@ public boolean removeIf(Predicate<? super E> filter) {
@java.io.Serial
private static final long serialVersionUID = -5429120189805438922L;

@SuppressWarnings("serial") // Conditionally serializable
private final NavigableSet<E> ns;

CheckedNavigableSet(NavigableSet<E> s, Class<E> type) {
@@ -3470,6 +3492,7 @@ public boolean removeIf(Predicate<? super E> filter) {
{
@java.io.Serial
private static final long serialVersionUID = 65247728283967356L;
@SuppressWarnings("serial") // Conditionally serializable
final List<E> list;

CheckedList(List<E> list, Class<E> type) {
@@ -3619,8 +3642,11 @@ public void sort(Comparator<? super E> c) {
@java.io.Serial
private static final long serialVersionUID = 5742860141034234728L;

@SuppressWarnings("serial") // Conditionally serializable
private final Map<K, V> m;
@SuppressWarnings("serial") // Conditionally serializable
final Class<K> keyType;
@SuppressWarnings("serial") // Conditionally serializable
final Class<V> valueType;

private void typeCheck(Object key, Object value) {
@@ -4019,6 +4045,7 @@ public boolean equals(Object o) {
@java.io.Serial
private static final long serialVersionUID = 1599671320688067438L;

@SuppressWarnings("serial") // Conditionally serializable
private final SortedMap<K, V> sm;

CheckedSortedMap(SortedMap<K, V> m,
@@ -4094,6 +4121,7 @@ public boolean equals(Object o) {
@java.io.Serial
private static final long serialVersionUID = -4852462692372534096L;

@SuppressWarnings("serial") // Conditionally serializable
private final NavigableMap<K, V> nm;

CheckedNavigableMap(NavigableMap<K, V> m,
@@ -4825,6 +4853,7 @@ public int characteristics() {
@java.io.Serial
private static final long serialVersionUID = 3193687207550431679L;

@SuppressWarnings("serial") // Conditionally serializable
private final E element;

SingletonSet(E e) {element = e;}
@@ -4879,6 +4908,7 @@ public int hashCode() {
@java.io.Serial
private static final long serialVersionUID = 3093736618740652951L;

@SuppressWarnings("serial") // Conditionally serializable
private final E element;

SingletonList(E obj) {element = obj;}
@@ -4948,7 +4978,9 @@ public int hashCode() {
@java.io.Serial
private static final long serialVersionUID = -6979724477215052911L;

@SuppressWarnings("serial") // Conditionally serializable
private final K k;
@SuppressWarnings("serial") // Conditionally serializable
private final V v;

SingletonMap(K key, V value) {
@@ -5087,6 +5119,7 @@ public int hashCode() {
private static final long serialVersionUID = 2739099268398711800L;

final int n;
@SuppressWarnings("serial") // Conditionally serializable
final E element;

CopiesList(int n, E e) {
@@ -5320,6 +5353,7 @@ public int compare(Comparable<Object> c1, Comparable<Object> c2) {
*
* @serial
*/
@SuppressWarnings("serial") // Conditionally serializable
final Comparator<T> cmp;

ReverseComparator2(Comparator<T> cmp) {
@@ -5601,6 +5635,7 @@ public static boolean disjoint(Collection<?> c1, Collection<?> c2) {
private static class SetFromMap<E> extends AbstractSet<E>
implements Set<E>, Serializable
{
@SuppressWarnings("serial") // Conditionally serializable
private final Map<E, Boolean> m; // The backing map
private transient Set<E> s; // Its keySet

@@ -5686,6 +5721,7 @@ private void readObject(java.io.ObjectInputStream stream)
implements Queue<E>, Serializable {
@java.io.Serial
private static final long serialVersionUID = 1802017725587941708L;
@SuppressWarnings("serial") // Conditionally serializable
private final Deque<E> q;
AsLIFOQueue(Deque<E> q) { this.q = q; }
public boolean add(E e) { q.addFirst(e); return true; }

0 comments on commit 3c9b6d8

Please sign in to comment.
You can’t perform that action at this time.