--- old/src/java.base/share/classes/java/util/EnumSet.java 2017-12-04 19:45:47.177905873 -0800 +++ new/src/java.base/share/classes/java/util/EnumSet.java 2017-12-04 19:45:46.969903833 -0800 @@ -75,7 +75,6 @@ * @author Josh Bloch * @since 1.5 * @see EnumMap - * @serial exclude */ @SuppressWarnings("serial") // No serialVersionUID due to usage of // serial proxy pattern @@ -85,12 +84,12 @@ /** * The class of all the elements of this set. */ - final Class elementType; + final transient Class elementType; /** - * All of the values comprising T. (Cached for performance.) + * All of the values comprising E. (Cached for performance.) */ - final Enum[] universe; + final transient Enum[] universe; EnumSet(ClasselementType, Enum[] universe) { this.elementType = elementType; @@ -416,7 +415,7 @@ * * @serial include */ - private static class SerializationProxy > + private static class SerializationProxy> implements java.io.Serializable { @@ -441,10 +440,18 @@ elements = set.toArray(ZERO_LENGTH_ENUM_ARRAY); } - // instead of cast to E, we should perhaps use elementType.cast() - // to avoid injection of forged stream, but it will slow the implementation + /** + * Returns an {@code EnumSet} object with initial state + * held by this proxy. + * + * @return a {@code EnumSet} object with initial state + * held by this proxy + */ @SuppressWarnings("unchecked") private Object readResolve() { + // instead of cast to E, we should perhaps use elementType.cast() + // to avoid injection of forged stream, but it will slow the + // implementation EnumSet result = EnumSet.noneOf(elementType); for (Enum e : elements) result.add((E)e); @@ -454,13 +461,24 @@ private static final long serialVersionUID = 362491234563181265L; } + /** + * Returns a + * + * SerializationProxy + * representing the state of this instance. + * + * @return a {@link SerializationProxy} + * representing the state of this instance + */ Object writeReplace() { return new SerializationProxy<>(this); } - // readObject method for the serialization proxy pattern - // See Effective Java, Second Ed., Item 78. - private void readObject(java.io.ObjectInputStream stream) + /** + * @param s the stream + * @throws java.io.InvalidObjectException always + */ + private void readObject(java.io.ObjectInputStream s) throws java.io.InvalidObjectException { throw new java.io.InvalidObjectException("Proxy required"); }