RFR: 8023340 : (xxs) Clarify that unmodifiable List.replaceAll() may not throw UOE if there are no items to be replaced.
Martin Buchholz
martinrb at google.com
Fri Sep 6 15:35:27 UTC 2013
ListIterator.set is specified to throw these exceptions:
* @throws UnsupportedOperationException if the {@code set} operation
* is not supported by this list iterator
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this list
* @throws IllegalArgumentException if some aspect of the specified
* element prevents it from being added to this list
* @throws IllegalStateException if neither {@code next} nor
* {@code previous} have been called, or {@code remove} or
* {@code add} have been called after the last call to
* {@code next} or {@code previous}
List.replaceAll invokes set (conceptually), so it needs to specify the same
exceptions, no? Many years ago I made an effort to make these sorts of
exception specs more consistent and accurate - a good outlet for my inner
pedant. Perhaps that needs to be done once more? Hmmmmmmm..... I notice
the above list is missing NullPointerException; that looks like a bug...
(my bad, I think)
Like David, I don't see the point of this change. UOE is not supposed to be
at the element level. If a List or ListIterator doesn't like a particular
element, it should be throwing one of the above exceptions (plus NPE).
On Thu, Sep 5, 2013 at 9:58 AM, Mike Duigou <mike.duigou at oracle.com> wrote:
> Hello all;
>
> A very small spec clarification for review. The spec clarification ensures
> that the behaviour of the default method can satisfy the needs of
> unmodifiable implementations.
>
> http://cr.openjdk.java.net/~mduigou/JDK-8023340/0/webrev/
>
> Thanks,
>
> Mike
More information about the core-libs-dev
mailing list