Evolution of records spec

Brian Goetz brian.goetz at oracle.com
Tue Nov 26 15:50:54 UTC 2019

Remi is correct that it is not possible to make a 100% compatible migration, but only for one of the following reasons: that records extend Record, and classes CANNOT extend Record.  The others are merely potholes on the way to compatibility (e.g., a class can be made final, it can have public ctors, etc.)  The same is true with enums, for the same reason.

That said, it would be reasonable to say _somewhere_ what a user should do if they want to maximize the compatibility of migrating between the two, as there is much that can be done.  Not sure if the JLS is the place to say that, though.  

> 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 <http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jls.html#jls-13.4.27>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20191126/ff868b7b/attachment-0001.html>

More information about the amber-spec-experts mailing list