-
Bug
-
Resolution: Fixed
-
P4
-
1.0-b21, 1.0-b22, 1.4.0
-
b95
-
generic, sparc
-
linux, solaris_2.6, solaris_7
Name: atR10191 Date: 03/06/2002
specification should define the behaviour of a call to
Container.remove(int index) with an invalid index
Current implementation can throw different exception under certain conditions.
When the Container is instantiated, the default constructor creates a Container
with a default array length of 4 null components.
Hence, attempts to remove a component from the Container at index < 0 or > 3
will result in an ArrayIndexOutOfBoundsException.
Attempts to remove a component from the Container at index >= 0 or <= 3, will
result in a NullPointerException if no component exists within that index of
the component array.
However, the exception thrown (if any) should be consistent across all
implementations. Hence, it is not acceptable for the NullPointerException to be
thrown as the RI has a default creation of an empty 4-element component array.
Another implementation might create an empty 5-element array that would result
in different behaviour with a different exception thrown.
At present, the specification does not define this behaviour - indicating that
the method should fail silently. Would it be more helpful to the user to have
this behaviour defined in order to indicate where the error has occurred?
With that in mind, should the specification document that this method can result
in an unchecked runtime exception in the
@throws tag of this method definition when called with an invalid index -
eg. IllegalArgumentException.
======================================================================
specification should define the behaviour of a call to
Container.remove(int index) with an invalid index
Current implementation can throw different exception under certain conditions.
When the Container is instantiated, the default constructor creates a Container
with a default array length of 4 null components.
Hence, attempts to remove a component from the Container at index < 0 or > 3
will result in an ArrayIndexOutOfBoundsException.
Attempts to remove a component from the Container at index >= 0 or <= 3, will
result in a NullPointerException if no component exists within that index of
the component array.
However, the exception thrown (if any) should be consistent across all
implementations. Hence, it is not acceptable for the NullPointerException to be
thrown as the RI has a default creation of an empty 4-element component array.
Another implementation might create an empty 5-element array that would result
in different behaviour with a different exception thrown.
At present, the specification does not define this behaviour - indicating that
the method should fail silently. Would it be more helpful to the user to have
this behaviour defined in order to indicate where the error has occurred?
With that in mind, should the specification document that this method can result
in an unchecked runtime exception in the
@throws tag of this method definition when called with an invalid index -
eg. IllegalArgumentException.
======================================================================
- duplicates
-
JDK-4629242 Need to specify behavior for Container.remove(int) for an invalid index
-
- Closed
-
- relates to
-
JDK-4687196 Container.add(Component, int) throws unspecified IllegalArgmentException
-
- Closed
-