RFR: 8178355: IdentityHashMap uses identity-based comparison for values everywhere except remove(K,V) and replace(K,V,V) [v4]

Daniel Fuchs dfuchs at openjdk.java.net
Wed Jun 1 09:35:55 UTC 2022


On Fri, 6 May 2022 22:05:35 GMT, liach <duke at openjdk.java.net> wrote:

>> Explicitly implement `remove` and `replace` in `IdentityHashMap` to compare values by identity. Updated API documentation of these two methods ([Preview](https://cr.openjdk.java.net/~liach/8178355/IdentityHashMap.html#remove(java.lang.Object,java.lang.Object))) to mention such behavior.
>
> liach has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Move tests
>  - Merge branch 'master' into fix/identityhashmap-default
>  - Fix assertions
>  - Revamp test and changes. Let ci run the tests
>  - Fix indent
>  - 8178355: IdentityHashMap uses identity-based comparison for values everywhere except remove(K,V) and replace(K,V,V)

src/java.base/share/classes/java/util/IdentityHashMap.java line 1392:

> 1390:      * and {@code value == v}, then this method removes the mapping
> 1391:      * for this key and returns {@code true}; otherwise it returns
> 1392:      * {@code false}.

The API documentation of containsKey() and containsValue() should probably be updated to mention reference equality too. This doesn't need to be carried out in this PR, but maybe a new issue should be logged to double check the completeness of the IdentityHashMap API documentation and see where adding some similar text makes sense.

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

PR: https://git.openjdk.java.net/jdk/pull/8259


More information about the core-libs-dev mailing list