Hi Brian, ----- Mail original ----- > De: "Brian Goetz" <brian.go...@oracle.com> > À: "amber-spec-experts" <amber-spec-experts@openjdk.java.net> > Envoyé: Mardi 23 Juillet 2019 20:32:08 > Objet: Records: migration compatibility
> In the course of exploring serialization support for records, Chris > asked about the compatible evolution modes for records. We have > explored this briefly before but let's put this down in one place. > > Since we are saying that records are a lot like enums, let's start with: > > A. Migrating a record-like class to a record > B. Migrating a record to a record-like class > > (which is analogous to refactoring between an enum and a class using the > type-safe enum pattern.) enums is a counter example here, no ? for enums, the only refactoring allowed is from a class to an enum, the other direction doesn't work because all enums inherits from java.lang.Enum. The JDK/javac implementation goes as far as - not allowing classical class to inherits from java.lang.Enum - using java.lang.Enum as a type in several public methods - testing at runtime that the class of an enum has to have the enum bit AND be a direct super type of java.lang.Enum (in case you generate your own bytecode) given that a record already have a different behavior at runtime than a nomrla class (the Record attribute), a public abstract class (AbstractRecord), the migration B seems unlikely. BTW, AbstractRecord also has the nasty side effect of not allowing inline record. Rémi