Semantics of getChars was incorrect. It should specify a begin

and end index, not a bunch of lengths
This commit is contained in:
Eric Scharff 2007-10-11 10:00:35 -06:00
parent e831a41e90
commit db2b7e8fa7

View File

@ -301,13 +301,13 @@ public final class String implements Comparable<String> {
return getBytes(); return getBytes();
} }
public void getChars(int srcOffset, int srcLength, public void getChars(int srcOffset, int srcEnd,
char[] dst, int dstOffset) char[] dst, int dstOffset)
{ {
if (srcOffset < 0 || srcOffset + srcLength > length) { if (srcOffset < 0 || srcEnd > length) {
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException();
} }
int srcLength = srcEnd-srcOffset;
if (data instanceof char[]) { if (data instanceof char[]) {
char[] src = (char[]) data; char[] src = (char[]) data;
System.arraycopy(src, offset + srcOffset, dst, dstOffset, srcLength); System.arraycopy(src, offset + srcOffset, dst, dstOffset, srcLength);