-
Bug
-
Resolution: Fixed
-
P3
-
1.2.2
-
kestrel
-
sparc
-
solaris_2.5
-
Verified
Name: saC57035 Date: 07/06/99
Specification for method java.util.Vector.indexOf(Object obj, int index) does not
explain its behavour for index < 0. In jdk1.2.2 it throws ArrayIndexOutOfBoundsException
while no Exception or IllegalArgumentException expected
The same problem exists in the specs of lastIndexOf().
----------- Javadoc cite
Returns the index of the first occurrence of the object argument in this vector at position index or
later in the vector, that is, the smallest value k such that elem.equals(elementData[k]) && (k >=
index) is true; returns -1 if the object is not found.
-----------
======================================================================
Sometimes jdk1.2.2 can throw ArrayIndexOutOfBoundsException
when for lastIndexOf(obj, index) index >= size(), sometimes not
It can return wrong results for obj == null
------------Test.java
import java.util.Vector;
public class Test {
public static void main(String [] args) {
Vector vect = new Vector();
for(int i=0; i<vect.capacity(); i++) {
System.out.println(vect.lastIndexOf(null, i));
}
}
}
------------
0
1
2
3
4
5
6
7
8
9
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at java.util.Vector.lastIndexOf(Vector.java, Compiled Code)
at Test.main(Test.java, Compiled Code)
------------
###@###.### 1999-07-08