Create java.util.stream.Stream from Iterator / Enumeration

Patrick Reinhart patrick at reini.net
Wed Jun 15 07:35:27 UTC 2016


> 
> Almost:
> 
> - you can use Enumeration.asIterator() rather than creating your own.

Right, for JDK 9 that will the right way. In the meantime under JDK 8
I will have to write my own ;-)

> - I don’t think you can assume the Iterator has an encounter order
> (even though there is a form of order related to class loader
> hierarchy, i.e. you cannot assume resources from a particular class
> loader are presented in any particular order, it might depend on how
> the zip/jar was created or the order in which resources are presented
> in the JDK image, which IIRC the order might optimized for booting
> up).

So in that case only IMMUTABLE will be appropriate, possibly also 
NONNULL
as far I understand the getResources() method documentation.

> I had marked ClassLoader as an area to use Stream (we went through a
> bunch of areas that return Enumeration and add Stream-based methods
> e.g. NetworkInterface) but we held off because Jigsaw was doing a lot
> of plumbing work.

I did already some hacking on the Jigsaw stuff and I liked it quit a 
lot.
The biggest problem I see is the time it takes to have all required
libraries being converted to Jigsaw too. All in all you all did a great
job there and I hope this will be appreciated in the end...

> It might be possible to revisit, it’s the type of enhancement we could
> get a Feature Complete (FC) extension for. I cannot promise anything
> here, but if you are looking for something to contribute that may be a
> good area of focus on now Jigsaw is settling down.

So, what do you suggest that should do now? Should I open a enhancement
Issue for that?

Patrick


More information about the core-libs-dev mailing list