This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: ArrayIndexOutOfBoundsException
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Subject: Patch: ArrayIndexOutOfBoundsException
- From: Tom Tromey <tromey at redhat dot com>
- Date: 24 May 2001 12:15:18 -0600
- Reply-To: tromey at redhat dot com
I'm checking this in. This cleans up our use of
ArrayIndexOutOfBoundsException -vs- StringIndexOutOfBoundsException in
a few places in String.
I'm putting this on the trunk only.
2001-05-24 Tom Tromey <tromey@redhat.com>
* java/lang/natString.cc (init): Throw
ArrayIndexOutOfBoundsException.
(getChars): Likewise.
(getBytes): Likewise.
(valueOf): Likewise.
Tom
Index: java/lang/natString.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natString.cc,v
retrieving revision 1.22
diff -u -r1.22 natString.cc
--- natString.cc 2001/05/24 05:40:37 1.22
+++ natString.cc 2001/05/24 18:04:48
@@ -445,7 +445,7 @@
jsize data_size = JvGetArrayLength (chars);
if (offset < 0 || count < 0 || offset + count < 0
|| offset + count > data_size)
- throw new StringIndexOutOfBoundsException;
+ throw new ArrayIndexOutOfBoundsException;
jcharArray array;
jchar *pdst;
if (! dont_copy)
@@ -475,7 +475,7 @@
jsize data_size = JvGetArrayLength (ascii);
if (offset < 0 || count < 0 || offset + count < 0
|| offset + count > data_size)
- throw new java::lang::StringIndexOutOfBoundsException;
+ throw new ArrayIndexOutOfBoundsException;
jcharArray array = JvNewCharArray(count);
jbyte *psrc = elements (ascii) + offset;
jchar *pdst = elements (array);
@@ -498,7 +498,7 @@
jsize data_size = JvGetArrayLength (bytes);
if (offset < 0 || count < 0 || offset + count < 0
|| offset + count > data_size)
- throw new StringIndexOutOfBoundsException;
+ throw new ArrayIndexOutOfBoundsException;
jcharArray array = JvNewCharArray (count);
gnu::gcj::convert::BytesToUnicode *converter
= gnu::gcj::convert::BytesToUnicode::getDecoder(encoding);
@@ -565,9 +565,10 @@
jcharArray dst, jint dstBegin)
{
jint dst_length = JvGetArrayLength (dst);
- if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
- || dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
+ if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count)
throw new java::lang::StringIndexOutOfBoundsException;
+ if (dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
+ throw new ArrayIndexOutOfBoundsException;
jchar *dPtr = elements (dst) + dstBegin;
jchar *sPtr = JvGetStringChars (this) + srcBegin;
jint i = srcEnd-srcBegin;
@@ -615,9 +616,10 @@
jbyteArray dst, jint dstBegin)
{
jint dst_length = JvGetArrayLength (dst);
- if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
- || dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
+ if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count)
throw new java::lang::StringIndexOutOfBoundsException;
+ if (dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
+ throw new ArrayIndexOutOfBoundsException;
jbyte *dPtr = elements (dst) + dstBegin;
jchar *sPtr = JvGetStringChars (this) + srcBegin;
jint i = srcEnd-srcBegin;
@@ -1007,7 +1009,7 @@
{
jint data_length = JvGetArrayLength (data);
if (offset < 0 || count < 0 || offset+count > data_length)
- throw new java::lang::IndexOutOfBoundsException;
+ throw new ArrayIndexOutOfBoundsException;
jstring result = JvAllocString(count);
jchar *sPtr = elements (data) + offset;
jchar *dPtr = JvGetStringChars(result);