JDK 12 RFR of JDK-8207751: Remove misleading serialVersionUID from JulienFields.Field

joe darcy joe.darcy at oracle.com
Tue Jul 17 23:19:26 UTC 2018


The nested enum java.time.temporal.JulianFields.Field declare a 
serialVersionUID field. Per the serialization spec, a serialVersionUID 
field in an enum is ignored.

"The process by which enum constants are serialized cannot be 
customized: any class-specific writeObject, readObject, 
readObjectNoData, writeReplace, and readResolve methods defined by enum 
types are ignored during serialization and deserialization. Similarly, 
any serialPersistentFields or serialVersionUID field declarations are 
also ignored--all enum types have a fixed serialVersionUID of 0L. 
Documenting serializable fields and data for enum types is unnecessary, 
since there is no variation in the type of data sent."


Therefore, this misleading field should be deleted; please review the 
patch below which does this.



--- a/src/java.base/share/classes/java/time/temporal/JulianFields.java 
Tue Jul 17 17:14:03 2018 -0400
+++ b/src/java.base/share/classes/java/time/temporal/JulianFields.java 
Tue Jul 17 16:07:22 2018 -0700
@@ -222,8 +222,6 @@
          MODIFIED_JULIAN_DAY("ModifiedJulianDay", DAYS, FOREVER, 40587L),
          RATA_DIE("RataDie", DAYS, FOREVER, 719163L);

-        private static final long serialVersionUID = -7501623920830201812L;
          private final transient String name;
          private final transient TemporalUnit baseUnit;
          private final transient TemporalUnit rangeUnit;

More information about the core-libs-dev mailing list