RFR: JDK-8329089: Empty immutable list throws the wrong exception type for remove(first | last) operations
Per Minborg
pminborg at openjdk.org
Thu Apr 4 07:39:09 UTC 2024
On Wed, 3 Apr 2024 15:09:15 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> This PR proposes to make empty immutable lists always throw UOE on `removeFirst` and `removeLast`.
>
> test/jdk/java/util/Collection/MOAT.java line 573:
>
>> 571: c::removeLast);
>> 572: }
>> 573:
>
> Would this test better if inserted in `testImmutableCollection(final Collection<T> c, T t)`, Line 477'ish.
> Or in `testImmutableList(final List<Integer> c)`, line 519.
Unfortunately, the `remove(F|L)` methods are not available for general collections. `testImmutableList()` is also applied for unmodifiable lists (like `Collections.emptyList()` and `Collections.nCopies(0, ...)`) that seem to behave differently (they throw NSEE). The latter have different specifications compared to an immutable list.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18581#discussion_r1551086873
More information about the core-libs-dev
mailing list