Consider a case where I've 10 fields in my Java class. What I want is, do some special handling for few of them (say 3) and rest of the fields been serialized via default ObjectOutputStream implementation. Is there a way to achieve this?
I can provide the implementation of writeObject(ObjectOutputStream os) in my class to specially handle these 3 fields, but how to default for rest of fields?
Object readResolve() throws ObjectStreamExceptionmethod, and set the defaults in there. See the spec for precise details on how this works withObjectInputStream.