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

Alan Bateman Alan.Bateman at oracle.com
Tue May 27 16:37:37 UTC 2014


On 13/02/2013 03:24, Michael Hixson wrote:
> 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
This mail just arrived but strangely has a timestamp of 2013.

In any case, it is bug JDK-8037945, fixed in 8u20 and 9. It would be 
good to bring up on jdk7u-dev to get it fixed there.

-Alan.


More information about the nio-dev mailing list