Hi Stuart!
Out of curiosity. What if someone does something like
if (it instanceof ListIterator) {
// optimized for bidirectional access
} else {
// slower algorithm
}
previous(), nextIndex() and previousIndex() methods are not declared to
be optional, so is it appropriate to throw UnsupportedOperationException
from them?
Someone may assume that if an object can be cast to ListIterator
interface, non-optional methods should not throw UOE.
With kind regards,
Ivan
On 6/25/18 3:06 PM, Stuart Marks wrote:
Hi all,
Please review this small changeset that ensures that calling
iterator() on an unmodifiable List (from List.of, et. al.) returns an
instance that cannot be downcast to ListIterator and used as such.
Bug:
https://bugs.openjdk.java.net/browse/JDK-8203670
Webrev:
http://cr.openjdk.java.net/~smarks/reviews/8203670/webrev.0/
Thanks,
s'marks
--
With kind regards,
Ivan Gerasimov