< prev index next >
src/hotspot/share/oops/typeArrayKlass.cpp
Print this page
rev 49800 : 8201593: Print array length in ArrayIndexOutOfBoundsException.
@@ -136,16 +136,35 @@
THROW(vmSymbols::java_lang_ArrayStoreException());
}
// Check is all offsets and lengths are non negative
if (src_pos < 0 || dst_pos < 0 || length < 0) {
- THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
+ // Pass specific exception reason.
+ ResourceMark rm;
+ stringStream ss;
+ if (src_pos < 0) {
+ ss.print("while trying to copy from index %i of a type array with length %i", src_pos, s->length());
+ } else if (dst_pos < 0) {
+ ss.print("while trying to copy to index %i of a type array with length %i", dst_pos, d->length());
+ } else {
+ ss.print("while trying to copy a negative range %i from a type array with length %i to a type array with length %i",
+ length, s->length(), d->length());
+ }
+ THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
}
// Check if the ranges are valid
if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
|| (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
- THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
+ // Pass specific exception reason.
+ ResourceMark rm;
+ stringStream ss;
+ if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
+ ss.print("while trying to copy from index %u of a type array with length %i", (unsigned int) length + (unsigned int) src_pos, s->length());
+ } else {
+ ss.print("while trying to copy to index %u of a type array with length %i", (unsigned int) length + (unsigned int) dst_pos, d->length());
+ }
+ THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
}
// Check zero copy
if (length == 0)
return;
< prev index next >