RFR: 8289389: Fix warnings: type should also implement hashCode() since it overrides Object.equals() [v2]
John Hendrikx
jhendrikx at openjdk.org
Fri Jul 8 23:49:44 UTC 2022
On Fri, 8 Jul 2022 21:53:50 GMT, Andy Goryachev <duke at openjdk.org> wrote:
>> - added missing hashCode() methods
>
> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
>
> 8289389: toExternalForm()
Just a general note, shouldn't most of these use `Objects.hash`?
I see a lot of code in the form of:
if(x == null) return 0;
return x.hashCode();
And even a few where hashes are calculated manually for two values:
x.hashCode() * 31 + y.hashCode();
These could be written as:
Objects.hash(x); // null check for free
Objects.hash(x, y); // free null checks and hashes are merged
modules/javafx.graphics/src/main/java/com/sun/javafx/css/CalculatedValue.java line 101:
> 99: }
> 100: return h;
> 101: }
Just an example, but wouldn't: `Objects.hash(relative, origin, value)` here work just as well?
-------------
PR: https://git.openjdk.org/jfx/pull/821
More information about the openjfx-dev
mailing list