Default method survey results
Rémi Forax
forax at univ-mlv.fr
Sun Aug 19 04:15:09 PDT 2012
On 08/18/2012 06:48 PM, Zhong Yu wrote:
> On Fri, Aug 17, 2012 at 3:50 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
>> On 08/17/2012 09:38 PM, Zhong Yu wrote:
>>> Another thing, remove() is a stateful operation, it depends on a prev
>>> next() call. If the caller invokes remove() without a prev next(), we
>>> should ideally throw IllegalStateException, regardless whether the
>>> operation is supported. I'm just saying; it's not a big deal either
>>> way.
>>>
>> No, it works the other way around, see the javadoc.
> I don't see that in javadoc.
In fact, it seems that there are both valid, if you consider that
throwing an IllegalStateException doesn't alter the collection,
see the javadoc of Collection:
The "destructive" methods contained in this interface, that is, the
methods that modify the collection on which they operate, are specified
to throw UnsupportedOperationException if this collection does not
support the operation. If this is the case, these methods may, but are
not required to, throw an UnsupportedOperationException if the
invocation would have no effect on the collection
Now, in practice, I've never seen any collection/iterator that checks
the preconditions before throwing an UOE.
Rémi
More information about the lambda-dev
mailing list