RFR: JDK-8274686 : java.util.UUID#hashCode() should use Long.hashCode()

PROgrm_JARvis github.com+7693005+jarviscraft at openjdk.java.net
Mon Oct 4 21:20:25 UTC 2021


This is trivial fix of [JDK-8274686](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8274686) which replaces manually-computed `int`-based `long` hash-code.

Because `Long#hashCode(long)` uses other hashing function than the one currently used here:

https://github.com/openjdk/jdk/blob/75d6688df9845ecb8f370b4cd2d5a36f13d3cdc0/src/java.base/share/classes/java/lang/Long.java#L1440-L1442

the value of `hashCode()` will produce different result, however this does not seem to be a breaking change as `UUID#hashCode()` is not specified.

---

Note: the comment to the bug states:

> Moved to JDK for further discussions of the proposed enhancement.

But as I there seemed to be no corresponding discussion in core-libs-dev and the change looks trivial, I considered that it is appropriate to open a PR which (if needed) may be used for discussion (especially, considering the fact that its comments get mirrored to the ML).

-------------

Commit messages:
 - fix: use `Long#hashCode(long)` for `UUID#hashCode()`

Changes: https://git.openjdk.java.net/jdk/pull/5811/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5811&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8274686
  Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5811.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5811/head:pull/5811

PR: https://git.openjdk.java.net/jdk/pull/5811


More information about the core-libs-dev mailing list