> Change the following collections to be strictly unmodifiable:
> 
>  - The reversed view of Collections.unmodifiableList()
>  - The reversed view Collections.unmodifiableSortedSet()
> 
> "Strictly unmodifiable" means that, if a mutator method is called that 
> doesn't actually attempt to modify the collection, then 
> UnsupportedOperationException will be thrown instead of the method returning 
> normally. For example, consider the following:
> 
>     Collections.unmodifiableList(new ArrayList<>()).reversed().remove("x") 
>     Collections.unmodifiableSortedSet(new TreeSet<>()).reversed().removeIf(x 
> -> false) 
> 
> Both of these currently return false. With this change, both will throw 
> UnsupportedOperationException.
> 
> This improves consistency of behavior of reversed views, which were all 
> intended to be strictly unmodifiable if the backing collection is 
> unmodifiable. This also improves consistency of the tests, which had some 
> cases commented out because of these edge cases.
> 
> See bug [JDK-8383625](https://bugs.openjdk.org/browse/JDK-8383625) for full 
> discussion.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Stuart Marks has updated the pull request incrementally with one additional 
commit since the last revision:

  Clean up "unmodifiable" data provider.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/31177/files
  - new: https://git.openjdk.org/jdk/pull/31177/files/898ea7af..4839eff1

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=31177&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31177&range=00-01

  Stats: 4 lines in 1 file changed: 0 ins; 2 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/31177.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31177/head:pull/31177

PR: https://git.openjdk.org/jdk/pull/31177

Reply via email to