RFR: 8289389: Fix warnings: type should also implement hashCode() since it overrides Object.equals() [v2]
Nir Lisker
nlisker at openjdk.org
Tue Jul 19 04:32:11 UTC 2022
On Mon, 11 Jul 2022 22:40:29 GMT, Andy Goryachev <duke at openjdk.org> wrote:
>> In order to reduce collisions, the hash of each component is typically added to `h * 31` even when that hash is 0, whereas you skip the `h = 31 * h` in the case of null. It might not be a problem in practice, since value and origin are unlikely to collide, being of different types, but you might want to look at it.
>>
>> In any case, I need to time to look at it, which I won't have until after JavaFX 19 RDP1, so let's leave this until then.
>
> you bring a good point, Kevin, thank you!
I would use `Boolean.hashCode(relative);` for a `boolean`.
Kevin, I checked Effective Java 3rd Edition and it also says to use 0 (or some other constant) for `null`.
-------------
PR: https://git.openjdk.org/jfx/pull/821
More information about the openjfx-dev
mailing list