RFR: 6323374: (coll) Optimize Collections.unmodifiable* and synchronized* [v5]
Ian Graves
igraves at openjdk.java.net
Thu Mar 4 02:04:43 UTC 2021
On Wed, 3 Mar 2021 23:29:33 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> Ian Graves has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Test refactoring. Adding implNote to modified methods
>
> 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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2596
More information about the core-libs-dev
mailing list