diff --git a/android/guava/src/com/google/common/cache/LocalCache.java b/android/guava/src/com/google/common/cache/LocalCache.java index 7cf7b5a6a3a8..931b89030dc8 100644 --- a/android/guava/src/com/google/common/cache/LocalCache.java +++ b/android/guava/src/com/google/common/cache/LocalCache.java @@ -54,6 +54,7 @@ import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.Weak; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.Serializable; import java.lang.ref.Reference; @@ -4748,6 +4749,10 @@ public void cleanUp() { Object writeReplace() { return new ManualSerializationProxy<>(localCache); } + + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use ManualSerializationProxy"); + } } static class LocalLoadingCache extends LocalManualCache @@ -4797,5 +4802,9 @@ public final V apply(K key) { Object writeReplace() { return new LoadingSerializationProxy<>(localCache); } + + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use LoadingSerializationProxy"); + } } } diff --git a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java index 50d7b126a27a..6ae7459f7bfa 100644 --- a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -15,6 +15,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.NoSuchElementException; import java.util.Set; @@ -162,6 +164,11 @@ Object writeReplace() { return new SerializedForm<>(domain); } + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + @GwtIncompatible // NavigableSet @Override ImmutableSortedSet createDescendingSet() { diff --git a/android/guava/src/com/google/common/collect/ImmutableBiMap.java b/android/guava/src/com/google/common/collect/ImmutableBiMap.java index 1de5bd10f073..b3646a267842 100644 --- a/android/guava/src/com/google/common/collect/ImmutableBiMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableBiMap.java @@ -23,6 +23,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; @@ -586,4 +588,8 @@ Builder makeBuilder(int size) { Object writeReplace() { return new SerializedForm<>(this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/android/guava/src/com/google/common/collect/ImmutableCollection.java b/android/guava/src/com/google/common/collect/ImmutableCollection.java index d5420e040100..72815bd7e6b8 100644 --- a/android/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/android/guava/src/com/google/common/collect/ImmutableCollection.java @@ -24,6 +24,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.AbstractCollection; import java.util.Arrays; @@ -361,6 +363,10 @@ Object writeReplace() { return new ImmutableList.SerializedForm(toArray()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** * Abstract base class for builders of {@link ImmutableCollection} types. * diff --git a/android/guava/src/com/google/common/collect/ImmutableEnumMap.java b/android/guava/src/com/google/common/collect/ImmutableEnumMap.java index 66680f0e909e..f4d60f5cda85 100644 --- a/android/guava/src/com/google/common/collect/ImmutableEnumMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableEnumMap.java @@ -20,6 +20,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.EnumMap; import javax.annotation.CheckForNull; @@ -100,6 +102,10 @@ Object writeReplace() { return new EnumSerializedForm<>(delegate); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use EnumSerializedForm"); + } + /* * This class is used to serialize ImmutableEnumMap instances. */ diff --git a/android/guava/src/com/google/common/collect/ImmutableEnumSet.java b/android/guava/src/com/google/common/collect/ImmutableEnumSet.java index 90787e5d6349..d7f56e106dcf 100644 --- a/android/guava/src/com/google/common/collect/ImmutableEnumSet.java +++ b/android/guava/src/com/google/common/collect/ImmutableEnumSet.java @@ -18,6 +18,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.concurrent.LazyInit; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collection; import java.util.EnumSet; @@ -126,6 +128,10 @@ Object writeReplace() { return new EnumSerializedForm(delegate); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /* * This class is used to serialize ImmutableEnumSet instances. */ diff --git a/android/guava/src/com/google/common/collect/ImmutableMap.java b/android/guava/src/com/google/common/collect/ImmutableMap.java index 1746ae0b41f3..ba00bfec3769 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableMap.java @@ -30,6 +30,8 @@ import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.WeakOuter; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.AbstractMap; import java.util.Arrays; @@ -1128,4 +1130,8 @@ Builder makeBuilder(int size) { Object writeReplace() { return new SerializedForm<>(this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java index 7ae6422e2dfb..6ee690e9d718 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java +++ b/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java @@ -18,6 +18,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Map.Entry; import javax.annotation.CheckForNull; @@ -108,6 +110,11 @@ Object writeReplace() { return new EntrySetSerializedForm<>(map()); } + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use EntrySetSerializedForm"); + } + @GwtIncompatible // serialization private static class EntrySetSerializedForm implements Serializable { final ImmutableMap map; diff --git a/android/guava/src/com/google/common/collect/ImmutableMultimap.java b/android/guava/src/com/google/common/collect/ImmutableMultimap.java index fa1f3a4c2ff4..701095e6ad5f 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMultimap.java +++ b/android/guava/src/com/google/common/collect/ImmutableMultimap.java @@ -29,6 +29,8 @@ import com.google.errorprone.annotations.DoNotMock; import com.google.j2objc.annotations.Weak; import com.google.j2objc.annotations.WeakOuter; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -662,6 +664,11 @@ boolean isPartialView() { Object writeReplace() { return new KeysSerializedForm(ImmutableMultimap.this); } + + @GwtIncompatible + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use KeysSerializedForm"); + } } @GwtIncompatible diff --git a/android/guava/src/com/google/common/collect/ImmutableMultiset.java b/android/guava/src/com/google/common/collect/ImmutableMultiset.java index ab281d4b3b3f..ad4fa15239e6 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMultiset.java +++ b/android/guava/src/com/google/common/collect/ImmutableMultiset.java @@ -25,6 +25,8 @@ import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.WeakOuter; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; @@ -365,6 +367,11 @@ Object writeReplace() { return new EntrySetSerializedForm(ImmutableMultiset.this); } + @GwtIncompatible + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use EntrySetSerializedForm"); + } + private static final long serialVersionUID = 0; } @@ -385,6 +392,11 @@ Object readResolve() { @Override abstract Object writeReplace(); + @GwtIncompatible + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** * Returns a new builder. The generated builder is equivalent to the builder created by the {@link * Builder} constructor. diff --git a/android/guava/src/com/google/common/collect/ImmutableRangeMap.java b/android/guava/src/com/google/common/collect/ImmutableRangeMap.java index aa7d91ce0065..1f4ee1d2b005 100644 --- a/android/guava/src/com/google/common/collect/ImmutableRangeMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableRangeMap.java @@ -25,6 +25,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collections; import java.util.List; @@ -406,5 +408,9 @@ Object writeReplace() { return new SerializedForm<>(asMapOfRanges()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static final long serialVersionUID = 0; } diff --git a/android/guava/src/com/google/common/collect/ImmutableRangeSet.java b/android/guava/src/com/google/common/collect/ImmutableRangeSet.java index a0eb5b5efb08..7dd13960a2f9 100644 --- a/android/guava/src/com/google/common/collect/ImmutableRangeSet.java +++ b/android/guava/src/com/google/common/collect/ImmutableRangeSet.java @@ -30,6 +30,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.concurrent.LazyInit; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collections; import java.util.Iterator; @@ -680,6 +682,10 @@ public String toString() { Object writeReplace() { return new AsSetSerializedForm(ranges, domain); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } private static class AsSetSerializedForm implements Serializable { @@ -829,4 +835,8 @@ Object readResolve() { Object writeReplace() { return new SerializedForm(ranges); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/android/guava/src/com/google/common/collect/ImmutableSet.java b/android/guava/src/com/google/common/collect/ImmutableSet.java index 1ff54e205baf..bdcab9a480f6 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSet.java +++ b/android/guava/src/com/google/common/collect/ImmutableSet.java @@ -29,6 +29,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.RetainedWith; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; @@ -384,6 +386,10 @@ Object writeReplace() { return new SerializedForm(toArray()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** * Returns a new builder. The generated builder is equivalent to the builder created by the {@link * Builder} constructor. diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMap.java b/android/guava/src/com/google/common/collect/ImmutableSortedMap.java index 709504eb28f1..796c3ac2f18f 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSortedMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableSortedMap.java @@ -26,6 +26,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.util.AbstractMap; import java.util.Arrays; import java.util.Comparator; @@ -1139,6 +1141,10 @@ Object writeReplace() { return new SerializedForm<>(this); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + // This class is never actually serialized directly, but we have to make the // warning go away (and suppressing would suppress for all nested classes too) private static final long serialVersionUID = 0; diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java index 2889a50ccfb6..2fae5b315a55 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java +++ b/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java @@ -23,6 +23,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.concurrent.LazyInit; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; @@ -671,4 +673,8 @@ Object readResolve() { Object writeReplace() { return new SerializedForm(this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/android/guava/src/com/google/common/collect/ImmutableTable.java b/android/guava/src/com/google/common/collect/ImmutableTable.java index 224df09c5b30..a599a030fd64 100644 --- a/android/guava/src/com/google/common/collect/ImmutableTable.java +++ b/android/guava/src/com/google/common/collect/ImmutableTable.java @@ -19,10 +19,13 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtCompatible; +import com.google.common.annotations.GwtIncompatible; import com.google.common.base.MoreObjects; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Comparator; import java.util.Iterator; @@ -453,4 +456,9 @@ Object readResolve() { final Object writeReplace() { return createSerializedForm(); } + + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/android/guava/src/com/google/common/collect/MapMakerInternalMap.java b/android/guava/src/com/google/common/collect/MapMakerInternalMap.java index bdef10ebc9e4..5572b94ac151 100644 --- a/android/guava/src/com/google/common/collect/MapMakerInternalMap.java +++ b/android/guava/src/com/google/common/collect/MapMakerInternalMap.java @@ -27,6 +27,7 @@ import com.google.j2objc.annotations.Weak; import com.google.j2objc.annotations.WeakOuter; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -2845,6 +2846,10 @@ Object writeReplace() { this); } + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializationProxy"); + } + /** * The actual object that gets serialized. Unfortunately, readResolve() doesn't get called when a * circular dependency is present, so the proxy must be able to behave as the map itself. diff --git a/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java b/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java index 2fcf0d664e3d..9f5e4f246425 100644 --- a/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java +++ b/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java @@ -21,6 +21,8 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.primitives.Primitives; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; @@ -172,6 +174,10 @@ private Object writeReplace() { return new SerializedForm(delegate()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** Serialized form of the map, to avoid serializing the constraint. */ private static final class SerializedForm implements Serializable { private final Map, B> backingMap; diff --git a/android/guava/src/com/google/common/collect/RegularContiguousSet.java b/android/guava/src/com/google/common/collect/RegularContiguousSet.java index 787606eb1f81..5eb9340927bc 100644 --- a/android/guava/src/com/google/common/collect/RegularContiguousSet.java +++ b/android/guava/src/com/google/common/collect/RegularContiguousSet.java @@ -22,6 +22,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collection; import javax.annotation.CheckForNull; @@ -241,5 +243,10 @@ Object writeReplace() { return new SerializedForm<>(range, domain); } + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static final long serialVersionUID = 0; } diff --git a/android/guava/src/com/google/common/hash/BloomFilter.java b/android/guava/src/com/google/common/hash/BloomFilter.java index 331d160dc0ce..d8b0690a76ae 100644 --- a/android/guava/src/com/google/common/hash/BloomFilter.java +++ b/android/guava/src/com/google/common/hash/BloomFilter.java @@ -31,6 +31,8 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Serializable; import java.math.RoundingMode; @@ -471,6 +473,10 @@ private Object writeReplace() { return new SerialForm(this); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static class SerialForm implements Serializable { final long[] data; final int numHashFunctions; diff --git a/android/guava/src/com/google/common/hash/Funnels.java b/android/guava/src/com/google/common/hash/Funnels.java index b8e63d504ddb..1d1d0a49948c 100644 --- a/android/guava/src/com/google/common/hash/Funnels.java +++ b/android/guava/src/com/google/common/hash/Funnels.java @@ -16,6 +16,8 @@ import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Serializable; import java.nio.charset.Charset; @@ -122,6 +124,10 @@ Object writeReplace() { return new SerializedForm(charset); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static class SerializedForm implements Serializable { private final String charsetCanonicalName; diff --git a/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java b/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java index 43fc087f28ad..0fe3347eae48 100644 --- a/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java +++ b/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java @@ -19,6 +19,8 @@ import static com.google.common.base.Preconditions.checkState; import com.google.errorprone.annotations.Immutable; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.nio.ByteBuffer; import java.security.MessageDigest; @@ -120,6 +122,10 @@ Object writeReplace() { return new SerializedForm(prototype.getAlgorithm(), bytes, toString); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** Hasher that updates a message digest. */ private static final class MessageDigestHasher extends AbstractByteHasher { private final MessageDigest digest; diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java index 707bcedde14e..052d5fed26ac 100644 --- a/guava/src/com/google/common/cache/LocalCache.java +++ b/guava/src/com/google/common/cache/LocalCache.java @@ -53,6 +53,7 @@ import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.Weak; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.Serializable; import java.lang.ref.Reference; @@ -4918,6 +4919,10 @@ public void cleanUp() { Object writeReplace() { return new ManualSerializationProxy<>(localCache); } + + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use ManualSerializationProxy"); + } } static class LocalLoadingCache extends LocalManualCache @@ -4967,5 +4972,9 @@ public final V apply(K key) { Object writeReplace() { return new LoadingSerializationProxy<>(localCache); } + + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use LoadingSerializationProxy"); + } } } diff --git a/guava/src/com/google/common/collect/EmptyContiguousSet.java b/guava/src/com/google/common/collect/EmptyContiguousSet.java index 50d7b126a27a..6ae7459f7bfa 100644 --- a/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -15,6 +15,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.NoSuchElementException; import java.util.Set; @@ -162,6 +164,11 @@ Object writeReplace() { return new SerializedForm<>(domain); } + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + @GwtIncompatible // NavigableSet @Override ImmutableSortedSet createDescendingSet() { diff --git a/guava/src/com/google/common/collect/HashBiMap.java b/guava/src/com/google/common/collect/HashBiMap.java index b0a5dd50edfd..64b568630bd7 100644 --- a/guava/src/com/google/common/collect/HashBiMap.java +++ b/guava/src/com/google/common/collect/HashBiMap.java @@ -29,6 +29,7 @@ import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.Weak; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -759,6 +760,11 @@ public void replaceAll(BiFunction function) { Object writeReplace() { return new InverseSerializedForm<>(HashBiMap.this); } + + @GwtIncompatible // serialization + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use InverseSerializedForm"); + } } private static final class InverseSerializedForm< diff --git a/guava/src/com/google/common/collect/ImmutableBiMap.java b/guava/src/com/google/common/collect/ImmutableBiMap.java index 4c222c1bf974..0ff48ec5e245 100644 --- a/guava/src/com/google/common/collect/ImmutableBiMap.java +++ b/guava/src/com/google/common/collect/ImmutableBiMap.java @@ -25,6 +25,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.util.Arrays; import java.util.Comparator; import java.util.Map; @@ -637,4 +639,8 @@ Builder makeBuilder(int size) { Object writeReplace() { return new SerializedForm<>(this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/guava/src/com/google/common/collect/ImmutableCollection.java b/guava/src/com/google/common/collect/ImmutableCollection.java index 314f83cce9ca..86f062b48497 100644 --- a/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/guava/src/com/google/common/collect/ImmutableCollection.java @@ -22,6 +22,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.AbstractCollection; import java.util.Collection; @@ -392,6 +394,10 @@ Object writeReplace() { return new ImmutableList.SerializedForm(toArray()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** * Abstract base class for builders of {@link ImmutableCollection} types. * diff --git a/guava/src/com/google/common/collect/ImmutableEnumMap.java b/guava/src/com/google/common/collect/ImmutableEnumMap.java index d1e10f97d0b9..f81377ba5d22 100644 --- a/guava/src/com/google/common/collect/ImmutableEnumMap.java +++ b/guava/src/com/google/common/collect/ImmutableEnumMap.java @@ -20,6 +20,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.EnumMap; import java.util.Spliterator; @@ -117,6 +119,10 @@ Object writeReplace() { return new EnumSerializedForm<>(delegate); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use EnumSerializedForm"); + } + /* * This class is used to serialize ImmutableEnumMap instances. */ diff --git a/guava/src/com/google/common/collect/ImmutableEnumSet.java b/guava/src/com/google/common/collect/ImmutableEnumSet.java index 32287bdd2baa..8bd265043f1b 100644 --- a/guava/src/com/google/common/collect/ImmutableEnumSet.java +++ b/guava/src/com/google/common/collect/ImmutableEnumSet.java @@ -18,6 +18,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.concurrent.LazyInit; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collection; import java.util.EnumSet; @@ -138,6 +140,10 @@ Object writeReplace() { return new EnumSerializedForm(delegate); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /* * This class is used to serialize ImmutableEnumSet instances. */ diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java index b24ed6c73236..7d29f6ed94f3 100644 --- a/guava/src/com/google/common/collect/ImmutableMap.java +++ b/guava/src/com/google/common/collect/ImmutableMap.java @@ -31,6 +31,8 @@ import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.WeakOuter; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.BitSet; @@ -1273,4 +1275,8 @@ Builder makeBuilder(int size) { Object writeReplace() { return new SerializedForm<>(this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java index 6f5503af5c11..126eae150524 100644 --- a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java +++ b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java @@ -18,6 +18,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Map.Entry; import java.util.Spliterator; @@ -120,6 +122,11 @@ Object writeReplace() { return new EntrySetSerializedForm<>(map()); } + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use EntrySetSerializedForm"); + } + @GwtIncompatible // serialization private static class EntrySetSerializedForm implements Serializable { final ImmutableMap map; diff --git a/guava/src/com/google/common/collect/ImmutableMultimap.java b/guava/src/com/google/common/collect/ImmutableMultimap.java index d16e1bc56267..7e274922d7d9 100644 --- a/guava/src/com/google/common/collect/ImmutableMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableMultimap.java @@ -29,6 +29,8 @@ import com.google.errorprone.annotations.DoNotMock; import com.google.j2objc.annotations.Weak; import com.google.j2objc.annotations.WeakOuter; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -686,6 +688,11 @@ boolean isPartialView() { Object writeReplace() { return new KeysSerializedForm(ImmutableMultimap.this); } + + @GwtIncompatible + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use KeysSerializedForm"); + } } @GwtIncompatible diff --git a/guava/src/com/google/common/collect/ImmutableMultiset.java b/guava/src/com/google/common/collect/ImmutableMultiset.java index b05ab3fe0108..ce481e47886f 100644 --- a/guava/src/com/google/common/collect/ImmutableMultiset.java +++ b/guava/src/com/google/common/collect/ImmutableMultiset.java @@ -26,6 +26,8 @@ import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.WeakOuter; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; @@ -407,6 +409,11 @@ Object writeReplace() { return new EntrySetSerializedForm(ImmutableMultiset.this); } + @GwtIncompatible + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use EntrySetSerializedForm"); + } + private static final long serialVersionUID = 0; } @@ -429,6 +436,11 @@ Object writeReplace() { return new SerializedForm(this); } + @GwtIncompatible + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** * Returns a new builder. The generated builder is equivalent to the builder created by the {@link * Builder} constructor. diff --git a/guava/src/com/google/common/collect/ImmutableRangeMap.java b/guava/src/com/google/common/collect/ImmutableRangeMap.java index 999a3014081e..221be507b3fe 100644 --- a/guava/src/com/google/common/collect/ImmutableRangeMap.java +++ b/guava/src/com/google/common/collect/ImmutableRangeMap.java @@ -25,6 +25,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collections; import java.util.List; @@ -439,5 +441,9 @@ Object writeReplace() { return new SerializedForm<>(asMapOfRanges()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static final long serialVersionUID = 0; } diff --git a/guava/src/com/google/common/collect/ImmutableRangeSet.java b/guava/src/com/google/common/collect/ImmutableRangeSet.java index f279aae0c56b..67c39a6ee6c9 100644 --- a/guava/src/com/google/common/collect/ImmutableRangeSet.java +++ b/guava/src/com/google/common/collect/ImmutableRangeSet.java @@ -30,6 +30,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.concurrent.LazyInit; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collections; import java.util.Iterator; @@ -693,6 +695,10 @@ public String toString() { Object writeReplace() { return new AsSetSerializedForm(ranges, domain); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } private static class AsSetSerializedForm implements Serializable { @@ -842,4 +848,8 @@ Object readResolve() { Object writeReplace() { return new SerializedForm(ranges); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java index 73d5b09bf2d9..1c1f971b5fce 100644 --- a/guava/src/com/google/common/collect/ImmutableSet.java +++ b/guava/src/com/google/common/collect/ImmutableSet.java @@ -29,6 +29,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.RetainedWith; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.math.RoundingMode; import java.util.Arrays; @@ -423,6 +425,10 @@ Object writeReplace() { return new SerializedForm(toArray()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** * Returns a new builder. The generated builder is equivalent to the builder created by the {@link * Builder} constructor. diff --git a/guava/src/com/google/common/collect/ImmutableSortedMap.java b/guava/src/com/google/common/collect/ImmutableSortedMap.java index ab971937d0a7..06da87b14777 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedMap.java +++ b/guava/src/com/google/common/collect/ImmutableSortedMap.java @@ -26,6 +26,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.util.AbstractMap; import java.util.Arrays; import java.util.Comparator; @@ -1160,6 +1162,10 @@ Object writeReplace() { return new SerializedForm<>(this); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + // This class is never actually serialized directly, but we have to make the // warning go away (and suppressing would suppress for all nested classes too) private static final long serialVersionUID = 0; diff --git a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java index 0638df04e09d..ae43053a9076 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java +++ b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java @@ -21,6 +21,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.concurrent.LazyInit; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; @@ -596,4 +598,8 @@ Object readResolve() { Object writeReplace() { return new SerializedForm(this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/guava/src/com/google/common/collect/ImmutableTable.java b/guava/src/com/google/common/collect/ImmutableTable.java index 033c271e6f69..2e1630832f26 100644 --- a/guava/src/com/google/common/collect/ImmutableTable.java +++ b/guava/src/com/google/common/collect/ImmutableTable.java @@ -19,10 +19,13 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtCompatible; +import com.google.common.annotations.GwtIncompatible; import com.google.common.base.MoreObjects; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Comparator; import java.util.Iterator; @@ -502,4 +505,9 @@ Object readResolve() { final Object writeReplace() { return createSerializedForm(); } + + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } } diff --git a/guava/src/com/google/common/collect/MapMakerInternalMap.java b/guava/src/com/google/common/collect/MapMakerInternalMap.java index 3725d9723b00..e34ab170d09e 100644 --- a/guava/src/com/google/common/collect/MapMakerInternalMap.java +++ b/guava/src/com/google/common/collect/MapMakerInternalMap.java @@ -27,6 +27,7 @@ import com.google.j2objc.annotations.Weak; import com.google.j2objc.annotations.WeakOuter; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -2840,6 +2841,10 @@ Object writeReplace() { this); } + private void readObject(ObjectInputStream in) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializationProxy"); + } + /** * The actual object that gets serialized. Unfortunately, readResolve() doesn't get called when a * circular dependency is present, so the proxy must be able to behave as the map itself. diff --git a/guava/src/com/google/common/collect/MutableClassToInstanceMap.java b/guava/src/com/google/common/collect/MutableClassToInstanceMap.java index 83fbe9447290..7f0e781fea2a 100644 --- a/guava/src/com/google/common/collect/MutableClassToInstanceMap.java +++ b/guava/src/com/google/common/collect/MutableClassToInstanceMap.java @@ -21,6 +21,8 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.primitives.Primitives; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; @@ -183,6 +185,10 @@ private Object writeReplace() { return new SerializedForm(delegate()); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** Serialized form of the map, to avoid serializing the constraint. */ private static final class SerializedForm implements Serializable { private final Map, B> backingMap; diff --git a/guava/src/com/google/common/collect/RegularContiguousSet.java b/guava/src/com/google/common/collect/RegularContiguousSet.java index 787606eb1f81..5eb9340927bc 100644 --- a/guava/src/com/google/common/collect/RegularContiguousSet.java +++ b/guava/src/com/google/common/collect/RegularContiguousSet.java @@ -22,6 +22,8 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collection; import javax.annotation.CheckForNull; @@ -241,5 +243,10 @@ Object writeReplace() { return new SerializedForm<>(range, domain); } + @GwtIncompatible // serialization + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static final long serialVersionUID = 0; } diff --git a/guava/src/com/google/common/collect/RegularImmutableBiMap.java b/guava/src/com/google/common/collect/RegularImmutableBiMap.java index b8bca958047b..4ca50abec840 100644 --- a/guava/src/com/google/common/collect/RegularImmutableBiMap.java +++ b/guava/src/com/google/common/collect/RegularImmutableBiMap.java @@ -30,6 +30,8 @@ import com.google.common.collect.RegularImmutableMap.BucketOverflowException; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.RetainedWith; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -295,6 +297,10 @@ boolean isPartialView() { Object writeReplace() { return new InverseSerializedForm<>(RegularImmutableBiMap.this); } + + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use InverseSerializedForm"); + } } private static class InverseSerializedForm implements Serializable { diff --git a/guava/src/com/google/common/hash/BloomFilter.java b/guava/src/com/google/common/hash/BloomFilter.java index 889ab5049cf7..3f1079ee8fd4 100644 --- a/guava/src/com/google/common/hash/BloomFilter.java +++ b/guava/src/com/google/common/hash/BloomFilter.java @@ -31,6 +31,8 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Serializable; import java.math.RoundingMode; @@ -538,6 +540,10 @@ private Object writeReplace() { return new SerialForm(this); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static class SerialForm implements Serializable { final long[] data; final int numHashFunctions; diff --git a/guava/src/com/google/common/hash/Funnels.java b/guava/src/com/google/common/hash/Funnels.java index b8e63d504ddb..1d1d0a49948c 100644 --- a/guava/src/com/google/common/hash/Funnels.java +++ b/guava/src/com/google/common/hash/Funnels.java @@ -16,6 +16,8 @@ import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Serializable; import java.nio.charset.Charset; @@ -122,6 +124,10 @@ Object writeReplace() { return new SerializedForm(charset); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + private static class SerializedForm implements Serializable { private final String charsetCanonicalName; diff --git a/guava/src/com/google/common/hash/MessageDigestHashFunction.java b/guava/src/com/google/common/hash/MessageDigestHashFunction.java index 43fc087f28ad..0fe3347eae48 100644 --- a/guava/src/com/google/common/hash/MessageDigestHashFunction.java +++ b/guava/src/com/google/common/hash/MessageDigestHashFunction.java @@ -19,6 +19,8 @@ import static com.google.common.base.Preconditions.checkState; import com.google.errorprone.annotations.Immutable; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.nio.ByteBuffer; import java.security.MessageDigest; @@ -120,6 +122,10 @@ Object writeReplace() { return new SerializedForm(prototype.getAlgorithm(), bytes, toString); } + private void readObject(ObjectInputStream stream) throws InvalidObjectException { + throw new InvalidObjectException("Use SerializedForm"); + } + /** Hasher that updates a message digest. */ private static final class MessageDigestHasher extends AbstractByteHasher { private final MessageDigest digest;