Hi Brian, given that a value type is constructed by a factory method (the constructor is desugared to a static method), why not making the serialization aware of that factory method.
Rémi ----- Mail original ----- > De: "Brian Goetz" <brian.go...@oracle.com> > À: "valhalla-spec-experts" <valhalla-spec-experts@openjdk.java.net> > Envoyé: Lundi 11 Mars 2019 20:30:09 > Objet: The gift that keeps on giving > One thing we need to figure out about value types is … serialization. > > (Pause for everyone to wishfully say “can’t we just disallow it for values?”, > and three pauses for people to get over this.) > > The problem is that serialization today proceeds by mutation, which might be > something we could deal with, but the mechanisms for “safer” serialization > (readObject, etc) also rely on mutation, and that’s harder. > > I’m working on a story here, but for now, let’s just put this on the list of > legacy pain that we will eventually have to deal with.