RFR: 6323374: (coll) Optimize Collections.unmodifiable* and synchronized* [v4]
Stuart Marks
smarks at openjdk.java.net
Tue Feb 23 23:21:39 UTC 2021
On Fri, 19 Feb 2021 01:52:51 GMT, liach <github.com+7806504+liach at openjdk.org> wrote:
>> Maybe it is not correct for UnmodifiableEntrySet::contains to short circuit? What if the implementation was changed to:
>>
>> `public boolean contains(Object o) {
>> if (!(o instanceof Map.Entry))
>> return c.contains(o); //false, NPE, or CCE
>> return c.contains(
>> new UnmodifiableEntry<>((Map.Entry<?,?>) o));
>> }`
>
> This however changes the behavior of unmodifiable maps compared to before; i.e. before for other entry sets, they could not throw exception if the object passed was not map entry; now they can.
Yes, it seems reasonable to decouple the `ImmutableCollections` issues from this change.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2596
More information about the core-libs-dev
mailing list