A library for implementing equals and hashCode

Kevin Bourrillion kevinb at google.com
Wed Apr 24 23:45:16 UTC 2019


On Wed, Apr 24, 2019 at 4:31 PM Stuart Marks <stuart.marks at oracle.com>
wrote:

However, I can see that
> some applications might want greater control over the actual hash
> function, so
> that capability probably will need to be provided through the API somehow.
>

I would disagree with this strongly. Use cases that require a *quality* hash
code really need to use a proper hashing library like (bias alert) Guava's.
It can produce quality results because its API is designed for that.

Object.hashCode() doesn't *need *to be a quality hash code! It only needs
to be good enough for in-memory hash tables, which is about as low as oneś
standards can possibly get. One should certainly avoid easily constructable
collisions... and then that's about all there is to worry about. And,
you *can't
*reasonably get much better than that anyway, because you will continually
find yourself depending on Integer.hashCode() and String.hashCode() etc.,
which will never get better than basic.


-- 
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190424/db65c20e/attachment.html>


More information about the amber-spec-experts mailing list