[records] updates for Preview 9. hashCode
kevinb at google.com
Tue Jan 14 00:23:53 UTC 2020
On Thu, Jan 9, 2020 at 8:46 PM John Rose <john.r.rose at oracle.com> wrote:
All we need to do is promise
> that a record type’s hashCode fulfills the Object contract, especially
> relative to the record’s equals method.
Yes! This, exactly. Thank you.
(It doesn't even matter if the words in the spec technically admit the
possibility it's implemented as `return 0`, because that's just a bad
implementation, and specs shouldn't have the burden of saying "by the way
this isn't/shouldn't be a bad implementation".)
As for toString() it doesn't have the same "Object already says it all"
situation, but I would question whether all the guarantees I currently see
in the patch are really necessary. How do users benefit from those
guarantees? I do like the "equal values -> equal strings" one (perhaps
noting that the inverse doesn't quite hold?).
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the amber-spec-experts