-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
According to the specifications:
"Elements cannot be added, removed, or replaced. Calling any mutator method on the List will always cause {@code UnsupportedOperationException} to be thrown."
However, calling `removeFirst()` or `removeLast()` on an empty immutable list will erroneously throw `java.util.NoSuchElementException` instead.
Reproducer:
assertThrows(UnsupportedOperationException.class, List.of()::removeFirst);
"Elements cannot be added, removed, or replaced. Calling any mutator method on the List will always cause {@code UnsupportedOperationException} to be thrown."
However, calling `removeFirst()` or `removeLast()` on an empty immutable list will erroneously throw `java.util.NoSuchElementException` instead.
Reproducer:
assertThrows(UnsupportedOperationException.class, List.of()::removeFirst);