RFR: 8323746: Add PathElement hashCode and equals
Per Minborg
pminborg at openjdk.org
Thu Feb 1 14:28:03 UTC 2024
On Wed, 31 Jan 2024 18:21:09 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This PR proposes to implement `hashCode()` and `equals()` methods for implementations of `PathElement`.
>>
>> In doing so, the previous `PathElementImpl` was removed and replaced in favor of distinct `record` implementations, each reflecting its own path element selection type. This also allowed the `PathKind` to be removed as this piece of information is now carried in the sealed type hierarchy.
>>
>> It is worth noting, the implementations resides in the `jdk.internal` package and consequently, they are not exposed to clients. So, we could use pattern matching (for example) internally but not in client code.
>
> src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java line 454:
>
>> 452: }
>> 453:
>> 454: public static final class SequenceElement
>
> Why are these not empty records?
I had that in the beginning but converted them to regular classes as they do not have any record components. But maybe it is better to make them all records for consistency?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17651#discussion_r1474565655
More information about the core-libs-dev
mailing list