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

    • Subcomponent:
    • Resolved In Build:
      b23
    • CPU:
      x86_64
    • OS:
      generic
    • Verification:
      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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: