RFR(s): 8072726: add adapter to convert Enumeration to Iterator

Paul Sandoz paul.sandoz at oracle.com
Tue May 19 17:03:45 UTC 2015


On May 19, 2015, at 6:13 PM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:

> On 19/05/15 12:07, Paul Sandoz wrote:
>>> Should anything be said also about default remove() method inherited from Iterator interface? Are custom asIterator() implementations allowed to return an Iterator that implements remove() in a way that actually removes elements?
>>> >
>> Since this method transfers control it seems a little mean to place such a restriction on the returned Iterator. Although, there is no clear means of stating to the caller whether such an iterator supports removal or not, but that seems to be generally the case for any Iterator returning method.
> 
> Ah... Interesting use case. I hadn't thought of that.
> 
> What should ConcurrentHashMap.keys().asIterator().remove() do?
> 

I would not have high expectations that it will not throw unless there was some explicit documentation. This is legacy stuff. One should really be using CHM.keysSet().

Paul.
 





More information about the core-libs-dev mailing list