This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: StringBuffer patch
- From: Mark Wielaard <mark at klomp dot org>
- To: java-patches at gcc dot gnu dot org
- Date: 22 Dec 2002 22:16:29 +0100
- Subject: Re: StringBuffer patch
- Organization:
- References: <1040591069.777.6.camel@elsschot>
Hi,
On Sun, 2002-12-22 at 22:04, Mark Wielaard wrote:
> 2002-12-21 Mark Wielaard <mark@klomp.org>
>
> * java/lang/StringBuffer.java (getChars): Remove wrong of dstOffset
> against count.
Now with patch attached.
Sorry,
Mark
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/StringBuffer.java,v
retrieving revision 1.13
diff -u -r1.13 StringBuffer.java
--- java/lang/StringBuffer.java 22 Jan 2002 22:40:16 -0000 1.13
+++ java/lang/StringBuffer.java 22 Dec 2002 20:43:19 -0000
@@ -308,26 +308,27 @@
}
}
- /** Get the specified array of characters.
- * The characters will be copied into the array you pass in.
- * @param srcOffset the index to start copying from in the
- * <code>StringBuffer</code>.
- * @param srcEnd the number of characters to copy.
- * @param dst the array to copy into.
- * @param dstOffset the index to start copying into <code>dst</code>.
- * @exception NullPointerException if dst is null.
- * @exception IndexOutOfBoundsException if any source or target
- * indices are out of range.
- * @see java.lang.System#arraycopy(java.lang.Object,int,java.lang.Object,int,int)
+ /**
+ * Get the specified array of characters. <code>srcOffset - srcEnd</code>
+ * characters will be copied into the array you pass in.
+ *
+ * @param srcOffset the index to start copying from (inclusive)
+ * @param srcEnd the index to stop copying from (exclusive)
+ * @param dst the array to copy into
+ * @param dstOffset the index to start copying into
+ * @throws NullPointerException if dst is null
+ * @throws IndexOutOfBoundsException if any source or target indices are
+ * out of range (while unspecified, source problems cause a
+ * StringIndexOutOfBoundsException, and dest problems cause an
+ * ArrayIndexOutOfBoundsException)
+ * @see System#arraycopy(Object, int, Object, int, int)
*/
- public synchronized void getChars (int srcOffset, int srcEnd,
- char[] dst, int dstOffset)
+ public synchronized void getChars(int srcOffset, int srcEnd,
+ char[] dst, int dstOffset)
{
- if (srcOffset < 0 || srcOffset > srcEnd)
- throw new StringIndexOutOfBoundsException (srcOffset);
int todo = srcEnd - srcOffset;
- if (srcEnd > count || dstOffset + todo > count)
- throw new StringIndexOutOfBoundsException (srcEnd);
+ if (srcOffset < 0 || srcEnd > count || todo < 0)
+ throw new StringIndexOutOfBoundsException();
System.arraycopy(value, srcOffset, dst, dstOffset, todo);
}