summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/util/ArrayList.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/util/ArrayList.java')
-rw-r--r--libjava/classpath/java/util/ArrayList.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/libjava/classpath/java/util/ArrayList.java b/libjava/classpath/java/util/ArrayList.java
index 0693049b53a..1fb25d80152 100644
--- a/libjava/classpath/java/util/ArrayList.java
+++ b/libjava/classpath/java/util/ArrayList.java
@@ -472,8 +472,7 @@ public class ArrayList<E> extends AbstractList<E>
// use of a negative index will cause an ArrayIndexOutOfBoundsException,
// a subclass of the required exception, with no effort on our part.
if (index > size)
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: "
- + size);
+ raiseBoundsError(index);
}
/**
@@ -488,11 +487,25 @@ public class ArrayList<E> extends AbstractList<E>
// use of a negative index will cause an ArrayIndexOutOfBoundsException,
// a subclass of the required exception, with no effort on our part.
if (index >= size)
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: "
- + size);
+ raiseBoundsError(index);
}
/**
+ * Raise the ArrayIndexOfOutBoundsException.
+ *
+ * @param index the index of the access
+ * @throws IndexOutOfBoundsException unconditionally
+ */
+ private void raiseBoundsError(int index)
+ {
+ // Implementaion note: put in a separate method to make the JITs job easier
+ // (separate common from uncommon code at method boundaries when trivial to
+ // do so).
+ throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+ }
+
+
+ /**
* Remove from this list all elements contained in the given collection.
* This is not public, due to Sun's API, but this performs in linear
* time while the default behavior of AbstractList would be quadratic.
OpenPOWER on IntegriCloud