Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.5
-
Java(TM) SE Runtime Environment (build 1.6.0_19-b04) MS Windows XP x64 SP2
Description
Bounds checking on ArrayList fails under certain circumstances.
Appears to happen when add() and/or insert() methods of ArrayList are used, and not when data is passed to a constructor
jUnit test demonstrating the issue will be attached in a follow up post.
public void simpleTest() {
org.apache.pivot.collections.List<String> pivot1 = new org.apache.pivot.collections.ArrayList<String>("A", "B", "C");
// Throws java.lang.IndexOutOfBoundsException
pivot1.get(3);
org.apache.pivot.collections.List<String> pivot2 = new org.apache.pivot.collections.ArrayList<String>();
// Returns null
System.out.println(pivot2.get(0));
pivot2.add("A");
pivot2.add("B");
pivot2.add("C");
// Returns null
System.out.println(pivot2.get(3));
java.util.List<String> java = new java.util.ArrayList<String>();
// Throws java.lang.IndexOutOfBoundsException
java.get(0);
java.add("A");
java.add("B");
java.add("C");
// Throws java.lang.IndexOutOfBoundsException
java.get(3);
}