AIOOB in UnixPath.normalize

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 8
    • Component/s: core-libs
    • None

      Attempting to normalize an empty path causes an exception

      /opt/jdk/1.8.0/bin/java -cp play/classes/ P ''
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at sun.nio.fs.UnixPath.normalize(UnixPath.java:508)
      at P.main(P.java:9)

      Here is the demo code:
      import java.nio.file.*;

      class P {
          public static void main(String... args) {
      for (String arg: args) {
                  System.out.println("'" + arg + "'"
      + " '" + Paths.get(arg) + "'"
      + " '" + Paths.get(arg).toAbsolutePath() + "'"
      + " '" + Paths.get(arg).normalize() + "'");
              }
          }
      }

            Assignee:
            Alan Bateman
            Reporter:
            Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: