----- Mail original ----- > De: "Tagir Valeev" <amae...@gmail.com> > À: "amber-spec-experts" <amber-spec-experts@openjdk.java.net> > Envoyé: Mardi 26 Novembre 2019 09:12:24 > Objet: Evolution of records spec
> Hello! > > The current spec draft [1] tells nothing about the possibility to > migrate an existing class to the record or vice versa. I believe such > a migration could be safe, taking into account all the implicit > declarations the records have. E.g. if I linked before to a library > final class named Point, called a constructor like Point(int, int) and > used equals/hashCode/toString, then converting it to the record > Point(int x, int y) in the library would not break my client code. > Should not we have some kind of explicit statement about > record<=>class binary compatibility ? It's not fully binary compatible because: - a record is final (and static for internal class) - a record inherits from j.l.Record - a record requires the canonical constructor to be public - a record has a special serialization if it implements Serializable - a record is self reflective (isRecord()/getComponents()). So moving from a class to a record is mostly binary compatible if the class is not Serializable, doesn't inherits from another class and has no subclass. Moving from a record to a class is not binary compatible. > > With best regards, > Tagir Valeev. Rémi > > [1] > http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jls.html#jls-13.4.27