Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8199485

(fs) Add equivalents of Paths.get to Path interface

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 11
    • core-libs
    • None
    • minimal
    • This change would add two methods so there should not be any compatibility issues.
    • Java API
    • SE

      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:

      1. Add java.nio.file.Path.of(String first, String... more) and java.nio.file.Path.of(URI uri).
      2. Excise most of the documentation of the java.nio.file.Paths.get methods and add notes and links redirecting the developer to the equivalent java.nio.file.Path.of methods.
      3. 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.

            bpb Brian Burkhalter
            alanb Alan Bateman
            Alan Bateman, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: