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

(coll spec) List.subList doc IndexOutOfBoundsException vs. IllegalArgumentException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      generic, x86
    • OS:
      generic, windows_7

      Description



      Name: bsT130419 Date: 09/24/2001


      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)


      The documentation for List.subList states that an IndexOutOfBoundsException will
      be thrown if fromIndex > toIndex. However, the documentation for
      AbstractList.subList claims that this will cause an IllegalArgumentException.
      The implementation of subList follows the latter, so the documentation of the
      former needs to be corrected.
      (Review ID: 132413)
      ======================================================================


      Most implementations of List within the JDK (and likely most outside of
      it as well) directly or indirectly extend AbstractList, and thus obey
      its version of the subList contract. However, at least one
      List implementation within the JDK (CopyOnWriteArrayList), and some
      unknown number without, implement List via a different route and
      reasonably obey List's version of the subList contract.

      The least disruptive course may be to codify the current reality of
      List.subList, and allow its implementations to throw either exception.

      ###@###.### 2005-2-02 03:09:54 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              bstrathesunw Bill Strathearn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: