Paths.get("").normalize() throws AIOOBE on linux

Michael Hixson michael.hixson at gmail.com
Wed Feb 13 03:24:34 UTC 2013


Hello,

I notice that on Linux, the following program throws an exception:

  import java.nio.file.Paths;
  public class HelloWorld {
    public static void main(String[] args) {
      Paths.get("").normalize();
    }
  }

  Exception in thread "main"   java.lang.ArrayIndexOutOfBoundsException: 0
          at sun.nio.fs.UnixPath.normalize(UnixPath.java:508)
          at HelloWorld.main(HelloWorld.java:4)

Meanwhile on Windows, no exception is thrown.  The following code prints "true":

  Path a = Paths.get("");
  Path b = a.normalize();
  System.out.println(a.equals(b));

Is this difference in behavior expected?

I'm using 1.7u13 in both places.

-Michael


More information about the nio-dev mailing list