-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6u26
-
x86
-
windows_7
FULL PRODUCT VERSION :
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
I use Mac OS X ver 10.7.1, but the problem is evident within the documentation so platform doesn't really matter
A DESCRIPTION OF THE PROBLEM :
AbstractList<E>.subList(fromIndex, toIndex) throws an IllegalArgumentException if toIndex < fromIndex.
This is at odds with the documentation for List<E>.subList(fromIndex, toIndex), which specifies that if toIndex < fromIndex, it should throw an IndexOutOfBoundsException.
Since AbstractList implements List, it should obey the contract of List, but in this instance it does not.
I know this is a duplicate of bug report #4506427, but that bug was reported 10 years ago, and it was claimed that this would be fixed in Java 5. Alas, it clearly has not been.
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
I use Mac OS X ver 10.7.1, but the problem is evident within the documentation so platform doesn't really matter
A DESCRIPTION OF THE PROBLEM :
AbstractList<E>.subList(fromIndex, toIndex) throws an IllegalArgumentException if toIndex < fromIndex.
This is at odds with the documentation for List<E>.subList(fromIndex, toIndex), which specifies that if toIndex < fromIndex, it should throw an IndexOutOfBoundsException.
Since AbstractList implements List, it should obey the contract of List, but in this instance it does not.
I know this is a duplicate of bug report #4506427, but that bug was reported 10 years ago, and it was claimed that this would be fixed in Java 5. Alas, it clearly has not been.
REPRODUCIBILITY :
This bug can be reproduced always.
- duplicates
-
JDK-4506427 (coll spec) List.subList doc IndexOutOfBoundsException vs. IllegalArgumentException
-
- Open
-