Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Uniform approach to serialization across collections #523

Closed
retronym opened this issue Mar 27, 2018 · 1 comment
Closed

Uniform approach to serialization across collections #523

retronym opened this issue Mar 27, 2018 · 1 comment
Assignees
Labels

Comments

@retronym
Copy link
Member

retronym commented Mar 27, 2018

Before shipping 2.13.0, we should come up with a uniform approach to serialization of collections.

To date, our approach has been -

  • make a collection Serializable
  • later, remember to add @SerialVersionUID as needed
  • later, switch to custom serialization (writeObject or writeReplace) to avoid directly serializing the internal structure, allowing us to change internals.

We also need to use custom serialization to deal with objects whose hash code changes on deserialization. We do this in mutable.HashMap. It appears to be missing from mutable.{HashMap, ChampHashMap} at the moment.

IMO, our default approach should be serializing a tag with the collection type, collection type specific config data (e.g. loadFactor), and then the elements. Deserialization would build a new collection with these elements. Details like class Map1, or the precise field layout of HashCollisionMapNode could be changed while remaining serialization compatible.

However, there is a gotcha with custom serialization: scala/bug#9237

In some classloader setups, we end up trying to deserialize the elements in the wrong classloader.

@retronym retronym changed the title Customize serialization across collections Uniform approach to serialization across collections Mar 27, 2018
@lrytz
Copy link
Member

lrytz commented Apr 19, 2018

cross-link scala/bug#6654 and scala/bug#7005 and scala/bug#8576

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants