JDK-4647973 : spec for Container.remove() incomplete
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.0-b21,1.0-b22,1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,solaris_2.6,solaris_7
  • CPU: generic,sparc
  • Submitted: 2002-03-06
  • Updated: 2006-08-04
  • Resolved: 2006-08-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b95Fixed
Related Reports
Duplicate :  
Relates :  
Description
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.
======================================================================

Comments
EVALUATION Fixed as part of 6449894, thus closing as duplicate
27-07-2006

EVALUATION it looks likeclosing this bug as fixed is more usable for submitter to verify fix.
27-07-2006

EVALUATION Should specify ArrayIndexOutOfBoundsException thrown there: if (index < 0 || index >= ncomponents) { throw new ArrayIndexOutOfBoundsException(index); }
18-05-2006

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: tiger-beta INTEGRATED IN: tiger-b28 tiger-beta
14-06-2004

PUBLIC COMMENTS .
10-06-2004

EVALUATION Reviewed by Brent. Fixed for tiger. ###@###.### 2003-10-13
13-10-2003