RFR: 6323374: (coll) Optimize Collections.unmodifiable* and synchronized* [v3]
jmehrens
github.com+28367473+jmehrens at openjdk.java.net
Fri Feb 19 00:10:39 UTC 2021
On Wed, 17 Feb 2021 19:12:19 GMT, Ian Graves <igraves at openjdk.org> wrote:
>> 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.
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));
}`
-------------
PR: https://git.openjdk.java.net/jdk/pull/2596
More information about the core-libs-dev
mailing list