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

(coll) Unchecked exception specifications of collection classes are missing or inaccurate

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • core-libs

      The collection interfaces have exception specifications like

           * @throws UnsupportedOperationException <tt>add</tt> is not supported by
           * this collection.
           * @throws ClassCastException class of the specified element prevents it
           * from being added to this collection.
           * @throws NullPointerException if the specified element is null and this
           * collection does not support null elements.
           * @throws IllegalArgumentException some aspect of this element prevents
           * it from being added to this collection.
           */
          boolean add(E o);

      When this method is doc'ed in extending/implementing classes/interfaces,
      a different set of exceptions must be spec'ed. Often IllegalArgumentException
      is never thrown, and often NullPointerException is a mandatory exception
      because null elements are never permitted.

      All such methods in all the collection classes must be carefully audited for
      correctness of all unchecked exceptions.

      javadoc by default does not inherit unchecked exception specifications,
      so a reader might assume from reading the specs that e.g. NullPointerException
      is never thrown.
      ###@###.### 2005-05-12 22:40:45 GMT

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: