8207690: Parsing API for classpath and similar path strings

Roger Riggs roger.riggs at oracle.com
Wed Sep 12 14:30:08 UTC 2018


Hi,

My original intention was to provide minimal support for parsing a 
property value
and handling OS specific behaviors (quoting).

java.nio.file.Paths is a bit of backwater (now that Path.of was added) 
and its factories are dedicated to handling Paths.

I considered a new type representing a search path but that seemed to 
expand the scope beyond the minimum.

Search path logic is not one of the high profile functions used by lots 
of developers and there seem to be many variations on how they are used.

It is also a slippery slope since it could easily expand to add many 
useful functions
that applications already deal with themselves.

  - Searching the path for a particular file or directory
  - Supporting patterns for matching files on the path, using filters or 
glob patterns
  - Caching of previous lookups or directory contents
  - Optimizing the search path, ignoring duplicate entries, etc.

If that's the direction this should go it expands the scope quite a bit.

Thanks, Roger

On 9/11/18 12:49 PM, mark.reinhold at oracle.com wrote:
> 2018/9/11 4:50:49 -0700, chris.hegarty at oracle.com:
>>> On 11 Sep 2018, at 10:24, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>>> On 10/09/2018 21:55, Roger Riggs wrote:
>>>> Nope! there's quoting on Windows that gets short changed with that work around.
>>>>
>>>> Other opinions?, Suggestions?
>>> One suggestion is reduce this down to one method that returns a
>>> stream rather than a collection. It could work lazily if you
>>> want. Something like:
>>>
>>>   Stream<String> splitSearchPath(String input)
>> I agree with Alan, this seems like the lowest-order primitive.
> Agreed, but it begs a question that applies to all these alternatives:
> Why does this API belong in java.nio.file.Paths?
>
> In other words, search paths are a different abstraction from filesystem
> paths.  Should they have their own class, even if it only winds up with
> a couple of static utility methods?  java.nio.file.SearchPath?
>
>      public class SearchPath {
>          public static Stream<String> splitToStream(String searchPath);
>          public static List<Path> splitToPaths(String searchPath);
>          public static String join(Collection<String>);
>      }
>
> - Mark



More information about the core-libs-dev mailing list