RFR: 8356486: ReverseOrderListView should override reversed() to return `base` [v2]

Stuart Marks smarks at openjdk.org
Fri May 9 18:53:54 UTC 2025


On Fri, 9 May 2025 07:03:30 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> There are some new collections (such as StableList) that are not covered in Basic. But maybe they should have their separate tests?
>
> `UnmodifiableSequencedCollection` double-reversed is not an identity function. But at least, it does not nest, as it returns a new USC with the underlying collection reversed.

Re the testing strategy: perhaps ideally, everything would be covered by MOAT, but its architecture is kind of cobbled together and doesn't support new features very well. The SequencedCollection/Basic tests are decent for SC but there's some uncomfortable overlap with MOAT. So there's some tension here.

For a new "kind" of collection like StableX it's unclear whether they should have their own tests or be added to a centralized place. It would be nice if StableX could rely on the tests for "typical" collection semantics. However, I'm not sure of their semantics of Stable collections when certain operations are performed. It looks like certain operations like contains(), indexOf(), and toArray() all eagerly evaluate the mapper function. So if the values have all been established, all the usual assertions for ordinary unmodifiable collections should apply. However, there are probably other operations that don't want to evaluate the element, so you'll want to have separate tests for those.

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

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


More information about the core-libs-dev mailing list