Some Java classes, like ConcurrentHashMap have a secret compatibility addition designed to allow for serializing and deserializing objects across different java versions. ConcurrentHashMap uses the serialPersistentFields list of fields to serialize, but the fields it lists don't exist! In its writeObject() implementation it computes the values for those non-existent fields, calls putFields() to write them out, then serializes additional data directly. In its readObject() method it uses defaultReadObject(), expecting it to discard those fields (they are only needed by a previous version of the class).
As Yoko implements its own serialization and deserialization routines, we need to support this. When deserializing we should discard any value found for one of the fields removed in a more recent java version, and when serializing we need to populate those fields with a default value. This mirrors the behavior of java.io.ObjectInputStream.
Some Java classes, like
ConcurrentHashMaphave a secret compatibility addition designed to allow for serializing and deserializing objects across different java versions.ConcurrentHashMapuses theserialPersistentFieldslist of fields to serialize, but the fields it lists don't exist! In itswriteObject()implementation it computes the values for those non-existent fields, callsputFields()to write them out, then serializes additional data directly. In itsreadObject()method it usesdefaultReadObject(), expecting it to discard those fields (they are only needed by a previous version of the class).As Yoko implements its own serialization and deserialization routines, we need to support this. When deserializing we should discard any value found for one of the fields removed in a more recent java version, and when serializing we need to populate those fields with a default value. This mirrors the behavior of
java.io.ObjectInputStream.