-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta2
-
generic
-
generic
-
Verified
Name: ssT124754 Date: 04/09/2001
java version "1.3.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)
Following code should make java.util.LinkedList throwing an
IllegalStateException, but it throws NoSuchElementException.
This is no serious bug, but affects test suites, which are
checking if thrown exceptions are meeting the specification.
public class LinkedListBugExample
{
public static void main(String[] args)
{
LinkedList l = new LinkedList();
for (int i = 0; i < 100; i++) {
l.add(new Integer(i));
}
Iterator it = l.iterator();
while (it.hasNext()) {
it.next();
it.remove();
}
try {
it.remove();
} catch (IllegalStateException ex) {
System.out.println("Expected exception thrown - bug not present.");
} catch (NoSuchElementException ex) {
System.out.println("Wrong exception thrown like specified in bug
report.");
}
}
}
(Review ID: 120373)
======================================================================