8207690: Parsing API for classpath and similar path strings

Alan Bateman Alan.Bateman at oracle.com
Tue Sep 11 14:29:06 UTC 2018


On 11/09/2018 14:09, Roger Riggs wrote:
>
> Streams are fine and easy to get from a List; but overall are a much 
> higher overhead than the list itself.
> And they can't be stored or re-used. Which would mean re-parsing the 
> string again.
I think returning Stream<String> will provide the most flexibility. The 
example usages in the webrev mostly want the elements in an array or 
they want to perform an action for each element and that is easily done 
with pipelines such as:

splitSearchPath(input).map(Path::of).toArray(Path[]::new)

splitSearchPath(input).map(Path::of).forEach(...)

If something wants to elements in a List or needs to cache the result 
then they can use a collector.

I agree we might need something special to optimize JDK startup but I 
don't think these cases should influence the API.

-Alan












More information about the core-libs-dev mailing list