--- a/src/hotspot/share/oops/objArrayKlass.cpp Sat May 12 17:22:56 2018 +0530
+++ b/src/hotspot/share/oops/objArrayKlass.cpp Mon May 07 09:11:21 2018 +0200
@@ -251,12 +251,34 @@
// 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("arraycopy: source index %d out of bounds for object array[%d]",
+ src_pos, s->length());
+ } else if (dst_pos < 0) {
+ ss.print("arraycopy: destination index %d out of bounds for object array[%d]",
+ dst_pos, d->length());
+ } else {
+ ss.print("arraycopy: length %d 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()) ) {
- THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
+ 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[%d]",
+ (unsigned int) length + (unsigned int) src_pos, s->length());
+ } else {
+ ss.print("arraycopy: last destination index %u out of bounds for object array[%d]",
+ (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