8207690: Parsing API for classpath and similar path strings

Remi Forax forax at univ-mlv.fr
Tue Sep 11 15:00:47 UTC 2018


I like splitSearchPath.

If think splitSearchPath should be a static method of java.io.File, perhaps with another variant in java.nio.file.Files also named splitSearchPath that returns a Stream of Path.

Rémi

----- Mail original -----
> De: "Alan Bateman" <Alan.Bateman at oracle.com>
> À: "Roger Riggs" <roger.riggs at oracle.com>, "jonathan gibbons" <jonathan.gibbons at oracle.com>, "core-libs-dev"
> <core-libs-dev at openjdk.java.net>
> Envoyé: Mardi 11 Septembre 2018 16:29:06
> Objet: Re: 8207690: Parsing API for classpath and similar path strings

> 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