aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2002-04-06 08:26:08 +0000
committerMark Wielaard <mark@gcc.gnu.org>2002-04-06 08:26:08 +0000
commit8e9603b0c204c9ea0099bc379be3de18da9f9488 (patch)
treedad90f94b7bb393dc0e6e3971b7076615caeb073 /libjava
parent392fc5b0689db61b8d5f8e2f8c9d29a548cd4faa (diff)
downloadgcc-8e9603b0c204c9ea0099bc379be3de18da9f9488.zip
gcc-8e9603b0c204c9ea0099bc379be3de18da9f9488.tar.gz
gcc-8e9603b0c204c9ea0099bc379be3de18da9f9488.tar.bz2
ArrayList.jva (removeRange): If toIndex == fromIndex do nothing...
* java/util/ArrayList.jva (removeRange): If toIndex == fromIndex do nothing, if toIndex < fromIndex throw IndexOutIfBoundsException. From-SVN: r51947
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog5
-rw-r--r--libjava/java/util/ArrayList.java10
2 files changed, 12 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 3c356d4..a48ba51 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,8 @@
+2002-04-05 Mark Wielaard <mark@klomp.org>
+
+ * java/util/ArrayList.jva (removeRange): If toIndex == fromIndex do
+ nothing, if toIndex < fromIndex throw IndexOutIfBoundsException.
+
2002-04-05 Adam Megacz <adam@xwt.org>
* exception.cc (abort): added static modifier
diff --git a/libjava/java/util/ArrayList.java b/libjava/java/util/ArrayList.java
index 34dc48a..59ce974 100644
--- a/libjava/java/util/ArrayList.java
+++ b/libjava/java/util/ArrayList.java
@@ -437,19 +437,23 @@ public class ArrayList extends AbstractList
/**
* Removes all elements in the half-open interval [fromIndex, toIndex).
- * You asked for it if you call this with invalid arguments.
+ * Does nothing when toIndex is equal to fromIndex.
*
* @param fromIndex the first index which will be removed
* @param toIndex one greater than the last index which will be removed
+ * @throws IndexOutOfBoundsException if fromIndex &gt; toIndex
*/
protected void removeRange(int fromIndex, int toIndex)
{
- if (fromIndex != toIndex)
+ int change = toIndex - fromIndex;
+ if (change > 0)
{
modCount++;
System.arraycopy(data, toIndex, data, fromIndex, size - toIndex);
- size -= toIndex - fromIndex;
+ size -= change;
}
+ else if (change < 0)
+ throw new IndexOutOfBoundsException();
}
/**