On Wed, 27 Mar 2024 17:36:28 GMT, Liam Miller-Cushon <[email protected]> wrote:
> This change overrides mutator methods in the implementation returned by
> `Map.of().entrySet()` to throw `UnsupportedOperationException`.
src/java.base/share/classes/java/util/ImmutableCollections.java line 1323:
> 1321: @Override
> 1322: public int hashCode() {
> 1323: return MapN.this.hashCode();
The hash code for a `Set` is defined as the sum of the elements in the `Set`
(hash(`null`) == 0). The `Map. Entry` hash code is defined the same way
`MapN.this.hashCode` operates so this seems right. It would be nice with a
couple of tests that assert this invariant.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18522#discussion_r1615591889