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

AIOOB in UnixPath.normalize

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8
    • 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() + "'");
              }
          }
      }

            alanb Alan Bateman
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: