Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8037857

Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex

    Details

      Backports

        Description

        The new JavaSE8 methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of the specified AIOOBE when end index is less than start index

        For example

        http://download.java.net/jdk8/docs/api/java/util/Arrays.html#spliterator-long:A-int-int-
        http://download.java.net/jdk8/docs/api/java/util/Arrays.html#stream-double:A-int-int-

        Specify
        "ArrayIndexOutOfBoundsException - if startInclusive is negative, endExclusive is less than startInclusive, or endExclusive is greater than the array size"

        For example this line:

                Arrays.spliterator(new int[]{1, 2, 3, 4, 5}, 2, 1);

        will throw "java.lang.IllegalArgumentException: origin(2) > fence(1)"


        The following tests which were added to JCK8a (and don't exist in JCK8) fail due to this issue:

        api/java_util/Arrays/spliterators/index.html#SpliteratorFromSubArray_Exceptions[endIsLessThanStart]
        api/java_util/Arrays/spliterators/index.html#SpliteratorFromLongSubArray_Exceptions[endIsLessThanStart]
        api/java_util/Arrays/spliterators/index.html#SpliteratorFromIntSubArray_Exceptions[endIsLessThanStart]
        api/java_util/Arrays/spliterators/index.html#SpliteratorFromDoubleSubArray_Exceptions[endIsLessThanStart]

        api/java_util/Arrays/streams/index.html#StreamFromDoubleSubArray_Exceptions[endIsLessThanStart]
        api/java_util/Arrays/streams/index.html#StreamFromIntSubArray_Exceptions[endIsLessThanStart]
        api/java_util/Arrays/streams/index.html#StreamFromLongSubArray_Exceptions[endIsLessThanStart]
        api/java_util/Arrays/streams/index.html#StreamFromSubArray_Exceptions[endIsLessThanStart]

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  psandoz Paul Sandoz
                  Reporter:
                  dbessono Dmitry Bessonov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: