8025002: "".codePoints().sorted().iterator().hasNext() causes NegativeArraySizeException
authorpsandoz
Wed, 18 Sep 2013 10:49:34 -0700
changeset 20182 7e90af95fc4e
parent 20181 7dadfbe7c0d3
child 20183 584504d38d79
8025002: "".codePoints().sorted().iterator().hasNext() causes NegativeArraySizeException Reviewed-by: henryjen, alanb
jdk/src/share/classes/java/lang/CharSequence.java
jdk/test/java/lang/CharSequence/DefaultTest.java
--- a/jdk/src/share/classes/java/lang/CharSequence.java	Thu Sep 19 10:06:30 2013 -0700
+++ b/jdk/src/share/classes/java/lang/CharSequence.java	Wed Sep 18 10:49:34 2013 -0700
@@ -228,7 +228,7 @@
                 Spliterators.spliteratorUnknownSize(
                         new CodePointIterator(),
                         Spliterator.ORDERED),
-                Spliterator.SUBSIZED | Spliterator.SIZED | Spliterator.ORDERED,
+                Spliterator.ORDERED,
                 false);
     }
 }
--- a/jdk/test/java/lang/CharSequence/DefaultTest.java	Thu Sep 19 10:06:30 2013 -0700
+++ b/jdk/test/java/lang/CharSequence/DefaultTest.java	Wed Sep 18 10:49:34 2013 -0700
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.PrimitiveIterator;
+import java.util.Spliterator;
 import java.util.stream.Collectors;
 
 import org.testng.annotations.Test;
@@ -34,7 +35,7 @@
 /*
  * @test
  * @summary Unit test for CharSequence default methods
- * @bug 8012665
+ * @bug 8012665 8025002
  * @run testng DefaultTest
  */
 
@@ -53,6 +54,12 @@
         assertEquals(list, Arrays.asList((int) 'a', (int) 'b', (int) 'c'));
     }
 
+    public void testCodePointsCharacteristics() {
+        Spliterator.OfInt s = "".codePoints().spliterator();
+        assertFalse(s.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED));
+        assertTrue(s.hasCharacteristics(Spliterator.ORDERED));
+    }
+
     @Test(expectedExceptions = NoSuchElementException.class)
     public void testEmptyCodePoints() {
         PrimitiveIterator.OfInt s = "".codePoints().iterator();