On Mon, 9 Nov 2026 16:23:50 GMT, Chen Liang <[email protected]> wrote:
>> Deprecate the `contains` method on `java.util.Hashtable`, >> `java.util.Properties`, and `java.util.concurrent.ConcurrentHashMap` for >> being confusing with `containsKey`. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Chen Liang 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: > > - Merge branch 'master' of github.com:openjdk/jdk into > cleanup/hashtable-contains > - Simplify specs > - Simplify specs > - Merge branch 'master' of github.com:openjdk/jdk into > cleanup/hashtable-contains > - Redundant suppression > - Deprecate the hashtable contains methods > This method is potentially confusing with containsKey. Unfortunately this sentence is syntactically incorrect. Perhaps this was meant instead: > This method is easily confused with containsKey. (Markup elided for clarity.) This is true, but it doesn't express what I was trying to say in my previous draft, which is that the name `contains` is just a bad name. It could mean that it looks for a matching key; it could mean that it looks for a matching value -- which it actually does, but it doesn't *say* that it does; it could mean that it looks for a matching key *or* value; or it could mean that it looks for a matching entry (key-value pair). We probably don't want to say all that, though. I included a cut-down explanation of the issue in my previous suggestion, copied here for convenience: > This method is potentially confusing because its name does not indicate > whether it checks for the presence of a key or a value. Use > {@link #containsValue(Object) containsValue} in preference to this method, or > use > {@link #containsKey(Object) containsKey} to check for the presence of a key. @liach I don't understand your objection to this. You reacted with an emoji (which GitHub labels as "confused") but then you suggested something different, but I don't understand what you were trying to accomplish with that suggestion. ------------- PR Comment: https://git.openjdk.org/jdk/pull/33593#issuecomment-6751991716
