Skip to content

Fix handling of Java's compatibility virtual objects during serialization #837

Description

@benjamin-confino

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions