Draft specification for java.lang.Record

Alex Buckley alex.buckley at oracle.com
Thu Aug 15 19:54:37 UTC 2019

On 8/15/2019 12:18 PM, Brian Goetz wrote:
>> Cloning: if a record class was to implement Cloneable, then the 
>> inherited implementation of Object::clone would not preserve copy 
>> equality (because, yes, cloning is not the same as copying). Recommend 
>> not implementing Cloneable? 
> We have an opportunity to do any of the following:
>   - Prohibit cloning by making Record::clone final;
>   - Be clone-agnostic by saying nothing;
>   - Promote cloning by making Record implement Cloneable, and having an 
> implementation of clone() either in Record.java, or having the compiler 
> generate it according to the obvious component-copying formula.

j.l.Record's copy-equality property suggests that copying a record 
instance should be done neither by shallow-copy nor by deep-copy. 
Bringing Cloneable's shallow-copy into the picture muddies things up. My 
view isn't worth much here, but prohibition of cloning looks good to me.


More information about the amber-spec-experts mailing list