RFR: 8345348: CSS media feature queries [v21]
Michael Strauß
mstrauss at openjdk.org
Wed May 7 09:24:23 UTC 2025
On Tue, 6 May 2025 15:55:31 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> so an array with the same values produces a different hash code.
>> in reality, it's highly unlikely.
>>
>> However, `FunctionExpression` is a `record`. What's the point of declaring it a record when you override `hashCode` and `equals`?
>
>> Why?
>
> made me think. the reason is _probably_ so that `class B extends A` would produce a different `hashCode`, but then `A.hashCode` should include not the class instance, but the `getClass()`:
>
>
> class A {
> public int hashCode() {
> return Objects.hash(getClass(), ...);
> }
> }
>
> class B extends A {
> // B.hashCode() produces a value different from A.hashCode()
> }
> so an array with the same values produces a different hash code. in reality, it's highly unlikely.
>
> However, `FunctionExpression` is a `record`. What's the point of declaring it a record when you override `hashCode` and `equals`?
Mainly to get the shorter syntax, finality, and immutability. It really doesn't make any sense to use method references in determining object equality, as they could be different even when the same method is referenced.
I'm using object equality for query expressions in tests, as it allows me to easily verify the shape of the expression tree, so there is value in doing that.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1655#discussion_r2077206803
More information about the openjfx-dev
mailing list