changeset 23571:2be40cc450b5

8037945: Paths.get("").normalize() throws ArrayIndexOutOfBoundsException Reviewed-by: chegar
author alanb
date Mon, 24 Mar 2014 15:09:47 +0000
parents 6b0a90ae5eaa
children 0b4b0e183619
files jdk/src/solaris/classes/sun/nio/fs/UnixPath.java jdk/test/java/nio/file/Path/PathOps.java
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java	Mon Mar 24 13:16:25 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java	Mon Mar 24 15:09:47 2014 +0000
@@ -482,7 +482,7 @@
     @Override
     public Path normalize() {
         final int count = getNameCount();
-        if (count == 0)
+        if (count == 0 || isEmpty())
             return this;
 
         boolean[] ignore = new boolean[count];      // true => ignore name
--- a/jdk/test/java/nio/file/Path/PathOps.java	Mon Mar 24 13:16:25 2014 +0100
+++ b/jdk/test/java/nio/file/Path/PathOps.java	Mon Mar 24 15:09:47 2014 +0000
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 6838333 6925932 7006126
+ * @bug 4313887 6838333 6925932 7006126 8037945
  * @summary Unit test for java.nio.file.Path path operations
  */
 
@@ -899,6 +899,8 @@
             .normalize("foo");
         test("/foo")
             .normalize("/foo");
+        test("")
+            .normalize("");
         test(".")
             .normalize("");
         test("..")