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

Stuart Marks stuart.marks at oracle.com
Tue May 19 15:28:54 UTC 2015



On 5/19/15 1:04 AM, Paul Sandoz wrote:
> On May 19, 2015, at 12:45 AM, Stuart Marks <stuart.marks at oracle.com> wrote:
>> OK, good. I tweaked it somewhat to say "if any method is called" instead of "operated on" to make it absolutely clear that the underlying Enumeration shouldn't be touched after the call to asIterator(). (Yes, that includes hasMoreElements.)
>>
>
> Ok. FWIW "operated on" is a term we have used in Stream and Spliterator.
>
> e.g.:
>
> * <p>Traversal of elements should be accomplished through the spliterator.
> * The behaviour of splitting and traversal is undefined if the iterator is
> * operated on after the spliterator is returned.

When I was reading the version of the Enumeration spec that had "operated on" I 
was thinking of hasMoreElements() implementations with side effects, and then I 
had a little argument with the voice in my head that said, "But I wasn't 
operating on the Enumeration, I just called hasMoreElements() to see if it had 
any more elements!" and so I sighed and said, "Just don't call any methods on 
Enumeration, OK??!"

(Yep, you heard it here first: we design APIs by having arguments with the 
voices in our heads.)

s'marks



More information about the core-libs-dev mailing list