On Thu, 18 Feb 2021 16:18:42 GMT, jmehrens <github.com+28367473+jmehr...@openjdk.org> wrote:
>> 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)); > }` 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. ------------- PR: https://git.openjdk.java.net/jdk/pull/2596