RFR: 8356486: ReverseOrderListView::reversed should return `base`

Chen Liang liach at openjdk.org
Thu May 8 14:46:55 UTC 2025


On Thu, 8 May 2025 14:30:28 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposed to let `ReverseOrderListView::reversed` return `base` so that nested reversed views are avoided.

test/jdk/java/util/Collection/MOAT.java line 507:

> 505:     private static <T> void testImmutableSeqColl(final SequencedCollection<T> c, T t) {
> 506:         SequencedCollection<T> r = c.reversed();
> 507:         if (r instanceof List<T> list && list.reversed() != c) {

Shouldn't all double-reverse be identity? Why is this restricted to lists?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25120#discussion_r2079865444


More information about the core-libs-dev mailing list