RFR: 8323746: Add PathElement hashCode and equals

Per Minborg pminborg at openjdk.org
Wed Jan 31 13:10:09 UTC 2024


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.

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

Commit messages:
 - Turn some record classes into regular classes
 - Rewrite PathElement implementations using records

Changes: https://git.openjdk.org/jdk/pull/17651/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17651&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8323746
  Stats: 182 lines in 3 files changed: 106 ins; 31 del; 45 mod
  Patch: https://git.openjdk.org/jdk/pull/17651.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17651/head:pull/17651

PR: https://git.openjdk.org/jdk/pull/17651


More information about the core-libs-dev mailing list