Summary
Add factory methods to java.nio.file.Path
as an alternative to the existing Paths.get
factory methods.
Problem
The static factory class java.nio.file.Paths
defines methods to convert a path String
, a sequence of Strings
, or a URI
to a java.nio.file.Path
. New developers don't know to use java.nio.file.Paths
to create Path
objects.
Solution
Add to java.nio.file.Path
the static methods of(String first, String... more)
and of(URI uri)
and update the documentation of java.nio.file.Paths
to redirect developers to these new methods.
Specification
Please refer to the attached specdiff (specdiff-path-of-8194746.zip
). The principal changes are:
- Add
java.nio.file.Path.of(String first, String... more)
andjava.nio.file.Path.of(URI uri)
. - Excise most of the documentation of the
java.nio.file.Paths.get
methods and add notes and links redirecting the developer to the equivalentjava.nio.file.Path.of
methods. Add an API note to the
java.nio.file.Paths
class documentation:It is recommended to obtain a {@code Path} via the {@code Path.of} methods instead of via the {@code get} methods defined in this class as this class may be deprecated in a future release.
- csr of
-
JDK-8194746 (fs) Add equivalents of Paths.get to Path interface
-
- Resolved
-