RFR [9] : Add default[Read|Write]Object to java.util.Date

Chris Hegarty chris.hegarty at oracle.com
Fri Mar 20 18:55:59 UTC 2015


Trivial change that came up a few months ago, and again recently, that java.util.Date should call default[Read|Write]Object to strictly conform to the Serialization spec ( even though it does not have any persistent state, which it could conceivably do at some point in the future, but probably won't ).

diff --git a/src/java.base/share/classes/java/util/Date.java b/src/java.base/share/classes/java/util/Date.java
--- a/src/java.base/share/classes/java/util/Date.java
+++ b/src/java.base/share/classes/java/util/Date.java
@@ -1317,6 +1317,7 @@
     private void writeObject(ObjectOutputStream s)
          throws IOException
     {
+        s.defaultWriteObject();
         s.writeLong(getTimeImpl());
     }
 
@@ -1326,6 +1327,7 @@
     private void readObject(ObjectInputStream s)
          throws IOException, ClassNotFoundException
     {
+        s.defaultReadObject();
         fastTime = s.readLong();
     }

-Chris.


More information about the core-libs-dev mailing list