< prev index next >

src/hotspot/share/oops/objArrayKlass.cpp

Print this page
rev 49869 : 8201593: Print array length in ArrayIndexOutOfBoundsException.
Reviewed-by: dholmes

*** 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,286 ---- 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("arraycopy source index %i out of bounds for object array[%i].", ! src_pos, s->length()); ! } else if (dst_pos < 0) { ! ss.print("arraycopy destination index %i out of bounds for object array[%i].", ! dst_pos, d->length()); ! } else { ! ss.print("arraycopy length %i is negative.", 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("arraycopy: last source index %u out of bounds for object array[%i].", ! (unsigned int) length + (unsigned int) src_pos, s->length()); ! } else { ! ss.print("arraycopy: last destination index %u out of bounds for object array[%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 >