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

Roger Riggs Roger.Riggs at Oracle.com
Fri Mar 20 19:13:16 UTC 2015


+1

On 3/20/2015 2:55 PM, Chris Hegarty wrote:
> 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