RFR: 8357272: Add overrides for all default methods to wrapper collections

Jaikiran Pai jpai at openjdk.org
Mon Jul 7 12:54:41 UTC 2025


On Wed, 28 May 2025 03:03:45 GMT, Stuart Marks <smarks at openjdk.org> wrote:

> This mostly just adds overrides to the wrapper implementations in java.util.Collections. However, in order to satisfy the test, some overrides are also added to ReverseOrderSortedMapView, which is used by the SortedMap wrapper keySet, values, and entrySet views. These overrides don't do anything except to call super, so they're arguably dead code. However, they enable all combinations of sequenced map views to be tested, which is valuable.

src/java.base/share/classes/java/util/Collections.java line 1600:

> 1598: 
> 1599:         public List<E> reversed() {
> 1600:             return ReverseOrderListView.of(this, false);

In some other overrides in this PR, we implement this like `return new UnmodifiableNavigableSet<>(ns.reversed());`. Is there a semantical difference between that style compared to using `ReverseOrderListView.of(this, false);`? In other words, for consistency, can this override be implemented as:


return new UnmodifiableList<>(list.reversed());

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25478#discussion_r2189989621


More information about the core-libs-dev mailing list