changeset 8168:f36714707c38

8025002: "".codePoints().sorted().iterator().hasNext() causes NegativeArraySizeException Reviewed-by: henryjen, alanb
author psandoz
date Wed, 18 Sep 2013 10:49:34 -0700
parents 278873b2b3f8
children 0ef7ddef9de0
files src/share/classes/java/lang/CharSequence.java test/java/lang/CharSequence/DefaultTest.java
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/CharSequence.java	Thu Sep 19 10:06:30 2013 -0700
+++ b/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/test/java/lang/CharSequence/DefaultTest.java	Thu Sep 19 10:06:30 2013 -0700
+++ b/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();