RFR: 8262742: (fs) Add Path::resolve with varargs string

Jaikiran Pai jpai at openjdk.org
Sat Jul 8 12:52:56 UTC 2023


On Sat, 8 Jul 2023 10:34:44 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Add to `java.nio.file.Path` methods which allow resolution of multiple descendants.
>
> src/java.base/share/classes/java/nio/file/Path.java line 551:
> 
>> 549:      * @since 22
>> 550:      */
>> 551:     default Path resolve(Path first, Path... more) {
> 
> It might be better to have a `(Path...)Path` overload, so that when you have an array of `Path`s or `String`s, you don’t have to manually extract the first element and copy the array using:
> 
> path.resolve(paths[0], Arrays.copyOfRange(paths, 1, paths.length))

Hello @ExE-Boss 

> It might be better to have a (Path...)Path

Do you mean introducing:

default Path resolve(Path... more) {
...
}

If so, then it would allow calls like:


Path p = ...
p.resolve();

(i.e. calling resolve without any parameter)
I think that would be odd and wrong for the API to allow that.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14805#discussion_r1257260603


More information about the nio-dev mailing list