< prev index next >

src/hotspot/share/oops/objArrayKlass.cpp

Print this page
rev 49800 : 8201593: Print array length in ArrayIndexOutOfBoundsException.

*** 249,264 **** 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()); } // 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()); } // Special case. Boundary cases must be checked first // This allows the following call: copy_array(s, s.length(), d.length(), 0). // This is correct, since the position is supposed to be an 'in between point', i.e., s.length(), --- 249,283 ---- THROW(vmSymbols::java_lang_ArrayStoreException()); } // Check is all offsets and lengths are non negative if (src_pos < 0 || dst_pos < 0 || length < 0) { ! // Pass specific exception reason. ! ResourceMark rm; ! stringStream ss; ! if (src_pos < 0) { ! ss.print("while trying to copy from index %i of an object array with length %i", src_pos, s->length()); ! } else if (dst_pos < 0) { ! ss.print("while trying to copy to index %i of an object array with length %i", dst_pos, d->length()); ! } else { ! ss.print("while trying to copy a negative range %i from an object array with length %i to an object 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()) ) { ! // 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 an object array with length %i", (unsigned int) length + (unsigned int) src_pos, s->length()); ! } else { ! ss.print("while trying to copy to index %u of an object array with length %i", (unsigned int) length + (unsigned int) dst_pos, d->length()); ! } ! THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); } // Special case. Boundary cases must be checked first // This allows the following call: copy_array(s, s.length(), d.length(), 0). // This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
< prev index next >