RFR: 8356605: JRSUIControl.hashCode and JRSUIState.hashCode can use Long.hasCode

Phil Race prr at openjdk.org
Mon May 12 22:52:52 UTC 2025


On Thu, 1 May 2025 16:16:29 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> Similar to #24959 and #24971 and #24987, apple.laf.JRSUIControl and apple.laf.JRSUIState in java.desktop can also be simplified similarly.
> 
> Replace manual bitwise operations in hashCode implementations of JRSUIControl/JRSUIState with Long::hashCode.

I'm not entirely convinced this "simplification" was worth anyone's time to understand and review. I've run tests and I don't see any failures, but it wasn't likely something we have a test for.
You'll need to fix the PR name

src/java.desktop/macosx/classes/apple/laf/JRSUIState.java line 186:

> 184:         @Override
> 185:         public int hashCode() {
> 186:             return super.hashCode() ^ Double.hashCode(value);

Since this uses Double.hashCode() not Long.hashCode() it would have been nice to have some comments on that. It took a bit of reading and following to learn that Double.hashCode() first uses Double.doubleToRawLongBits and then calls out to Long.hashCode

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

Marked as reviewed by prr (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/24989#pullrequestreview-2834788162
PR Review Comment: https://git.openjdk.org/jdk/pull/24989#discussion_r2085638753


More information about the client-libs-dev mailing list