String.getChars behaviour differs from Sun implementation

Tom Tromey tromey@redhat.com
Thu May 24 09:52:00 GMT 2001


>>>>> "Erwin" == Erwin Bolwidt <ejb@klomp.org> writes:

Erwin> 		char[] array = new char[0];
Erwin> 		"foo".getChars(0, 3, array, 0);

Erwin> But it seems logical to me that you get a
Erwin> StringIndexOutOfBoundsException if the first two parameters of
Erwin> the getChars method are wrong (they point to the start and end
Erwin> character within the string) and an
Erwin> ArrayIndexOutOfBoundsException if the array is too small or the
Erwin> last argument, the start index in the array, is negative or too
Erwin> big.

I agree.  This seems like the most logical approach to me as well.  I
have a patch for this which I'll check in soon.  I'm only going to put
it on the trunk though.  I don't think this is critical enough for
3.0.

Tom



More information about the Java mailing list