On Wed, 17 Feb 2021 02:27:57 GMT, liach <github.com+7806504+li...@openjdk.org> wrote:
>> src/java.base/share/classes/java/util/Collections.java line 1130: >> >>> 1128: public static <T> Set<T> unmodifiableSet(Set<? extends T> s) { >>> 1129: if(s.getClass() == UnmodifiableSet.class || >>> 1130: s.getClass() == ImmutableCollections.Set12.class || >> >> These might be problematic: `ImmutableCollections.Set*` differs in behavior >> subtly from `UnmodifiableSet`, e.g., `set.contains(null)` will throw an NPE. >> I'd limit the check and optimization to `UnmodifiableSet` here > > No? This unmodifiable set here just delegates call to the backing field `c`, > so all exceptions from `c`'s calls are just delegated, aren't they? The NPE > will still be thrown; it's just that the stack trace will be different (i.e. > one more level of call in the stacktrace) Yes, my bad. There might be more issues similar to the one @michaelhixson points out elsewhere in this PR, so a thorough review is probably needed here. ------------- PR: https://git.openjdk.java.net/jdk/pull/2596