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

(fs) Path.getParent() javadoc error

    XMLWordPrintable

Details

    • b105
    • generic
    • generic

    Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Path.getParent() (https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#getParent--) describes it's behavior as equivalent to `subpath(0, getNameCount()-1)` "if this path has one or more elements, and no root component".

      However if the Path has exactly one element, the behavior of these two methods differs; .getParent() returns null, whereas .subpath() raises an IllegalArgumentException "if endIndex is less than or equal to beginIndex".

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Path demo = Paths.get("file");
      assert demo.getParent() == null;
      demo.subpath(0, demo.getNameCount()-1); // raises an IllegalArgumentException


      REPRODUCIBILITY :
      This bug can be reproduced always.

      Attachments

        Activity

          People

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: