RFR: 8368178: Add specialization of SequencedCollection methods to emptyList, singletonList and nCopies [v2]
Tagir F. Valeev
tvaleev at openjdk.org
Sun Sep 21 16:47:18 UTC 2025
On Sun, 21 Sep 2025 10:31:06 GMT, Tagir F. Valeev <tvaleev at openjdk.org> wrote:
>> Please review this small change. If you have more ideas which classes may miss specializations of SequencedCollection methods, I can add them to this PR as well.
>
> Tagir F. Valeev has updated the pull request incrementally with two additional commits since the last revision:
>
> - Remove extra asterisk to prevent jtreg comment from being parsed as javadoc
> - JDK-8368178 Add specialization of SequencedCollection methods to emptyList, singletonList and nCopies
Yes, implSpec describes the implementation of a concrete default method without requiring anybody to follow the same restrictions. And you're right, returning the original collection is the easiest and most optimal thing one can do. So I think we are not restricted to return this from this.reversed().reversed().
Serialization is already inconsistent. We can't say that the result of reversed() is never serializable, because reversed().reversed() call may again return the serializable collection. In any case, let's wait for @stuart-marks opinion.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27406#issuecomment-3316110660
More information about the core-libs-dev
mailing list