On Thu, 4 Mar 2021 02:01:02 GMT, Ian Graves <igra...@openjdk.org> wrote:
>> src/java.base/share/classes/java/util/Collections.java line 1168: >> >>> 1166: */ >>> 1167: public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> >>> s) { >>> 1168: if (s.getClass() == UnmodifiableSortedSet.class) { >> >> Should a check like this also included "|| == >> UnmodifiableNavigableSet.class" or was there an explicit decision that the >> cost/benefit is not worthwhile, unlike in the case of unmodifiableList below? > > This is a good point. The case of unmodifiableList is such because the method > can return two different classes depending the nature of the argument. I feel > as though if we made this change here, we should consider doing the same > check for vanilla unmodifiableSet to ensure it, too, doesn't wrap its > subclasses. I'm amenable to this. To the second part of the question, there was no explicit cost/benefit analysis RE List or this case. ------------- PR: https://git.openjdk.java.net/jdk/pull/2596