Inline Record
Brian Goetz
brian.goetz at oracle.com
Thu May 7 13:47:07 UTC 2020
The implementation in Object is
public boolean equals(Object obj) {
return (this == obj);
}
This _already_ has exactly the default semantics we want for both
inlines and identities. Records layer their implementation atop it,
regardless of inline-ness.
On 5/6/2020 7:11 PM, John Rose wrote:
> On May 6, 2020, at 3:42 PM, Brian Goetz <brian.goetz at oracle.com
> <mailto:brian.goetz at oracle.com>> wrote:
>>
>> Eventually, inline classes will inherit eq/hashCode from Object.
>
> Crazy half-baked idea of the moment:
>
> Factor the equals/hashCode/toString methods for records into
> static methods (in ju.Objects) which are configurable appropriately,
> and have a default configuration. Use ClassValue for performance.
>
> Then define equals/hashCode/toString in jl.Object (yes, Object)
> to call those methods, *when the receiver is a Record and/or an inline*.
>
> Two ideas here: 1. No per-class indy or BSM at all, but a ClassValue
> instead. (We should do this for Record anyway.) 2. Push the
> specification
> all the way up to Object. (2 makes more sense for inlines than for
> Record, since it’s natural to define equals/hashCode/toString in
> the class hierarchy, if there’s a place to put it. There isn’t for
> inlines.)
>
> — John
More information about the amber-dev
mailing list