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

(fs) NullPointerException not thrown when first argument to Path.of or Paths.get is null

    XMLWordPrintable

Details

    • b23
    • x86_64
    • generic
    • Verified

    Description

      A DESCRIPTION OF THE PROBLEM :
      First argument of java.nio.file.Paths.get(String first, String... more) method allows null parameter and transforms it to "null" string.

      Example code:

      java.nio.file.Path path = java.nio.file.Paths.get(null, "a");
      System.out.println(path);
      System.out.println(path.toAbsolutePath());

      Output:
      null\a
      c:\Program Files\Java\jdk-15\bin\null\a

      Looks like a bug for me.
      Also JavaDoc for java.nio.file package state "Unless otherwise noted, passing a null argument to a constructor or method of any class or interface in this package will cause a NullPointerException to be thrown.".


      FREQUENCY : always

      Attachments

        Issue Links

          There are no Sub-Tasks for this issue.

          Activity

            People

              bpb Brian Burkhalter
              pnarayanaswa Praveen Narayanaswamy
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: