RFR: 6323374: (coll) Optimize Collections.unmodifiable* and synchronized* [v2]

Ian Graves igraves at openjdk.java.net
Wed Feb 17 19:14:38 UTC 2021


On Wed, 17 Feb 2021 18:24:39 GMT, Ian Graves <igraves at openjdk.org> wrote:

>> 2 remarks:
>> 1. MapN's entry set extends abstract set, whose `contains` is null-friendly like https://github.com/openjdk/jdk/blob/cb84539d56209a6687c4ec71a61fdbe6f06a46ea/src/java.base/share/classes/java/util/AbstractCollection.java#L104
>> 2. The problem of unmodifiable map's entry set not always delegating everything to the backing entry set still exists. https://github.com/openjdk/jdk/blob/cb84539d56209a6687c4ec71a61fdbe6f06a46ea/src/java.base/share/classes/java/util/Collections.java#L1724 This will bypass the underlying logic when the argument is `null` or not an entry.
>> 
>> The behavior pointed out by michaelhixson is the conglomeration of these 2 unspecified behaviors.
>
> This raises some interesting issues and makes me wonder if we should allow a single-wrap of the `ImmutableCollections` classes for now to make this less onerous.

Yes -- I think in response to this it makes more sense to pull the `ImmutableCollections` classes out for now and only focus on the wrapping of the classes within `Collections` so we aren't blocked by studying and rectifying these inconsistencies.

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

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


More information about the core-libs-dev mailing list