United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6269713 : (coll) Unchecked exception specifications of collection classes are missing or inaccurate

Details
Type:
Bug
Submit Date:
2005-05-12
Status:
Resolved
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2005-09-04
Component:
core-libs
OS:
generic
Sub-Component:
java.util:collections
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

Description
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

                                    

Comments
EVALUATION

Will be fixed as part of the jsr166x project.
###@###.### 2005-05-12 22:42:12 GMT
                                     
2005-05-12



Hardware and Software, Engineered to Work Together