diff -r 8e17fffa0a4b -r 3fbae7b9ddb5 src/hotspot/share/oops/objArrayKlass.cpp --- a/src/hotspot/share/oops/objArrayKlass.cpp Sat Jun 16 07:05:09 2018 +0200 +++ b/src/hotspot/share/oops/objArrayKlass.cpp Fri Jun 15 12:25:53 2018 +0200 @@ -235,7 +235,19 @@ // slow case: need individual subtype checks // note: don't use obj_at_put below because it includes a redundant store check if (!ArrayAccess::oop_arraycopy(s, src_offset, d, dst_offset, length)) { - THROW(vmSymbols::java_lang_ArrayStoreException()); + ResourceMark rm(THREAD); + stringStream ss; + if (!bound->is_subtype_of(stype)) { + ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]", + stype->external_name(), bound->external_name()); + } else { + // oop_arraycopy should return the index in the source array that + // contains the problematic oop. + ss.print("arraycopy: element type mismatch: can not cast one of the elements" + " of %s[] to the type of the destination array, %s", + stype->external_name(), bound->external_name()); + } + THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); } } } @@ -246,13 +258,21 @@ assert(s->is_objArray(), "must be obj array"); if (!d->is_objArray()) { - THROW(vmSymbols::java_lang_ArrayStoreException()); + ResourceMark rm(THREAD); + stringStream ss; + if (d->is_typeArray()) { + ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]", + type2name_tab[ArrayKlass::cast(d->klass())->element_type()]); + } else { + ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name()); + } + THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); } // Check is all offsets and lengths are non negative if (src_pos < 0 || dst_pos < 0 || length < 0) { // Pass specific exception reason. - ResourceMark rm; + ResourceMark rm(THREAD); stringStream ss; if (src_pos < 0) { ss.print("arraycopy: source index %d out of bounds for object array[%d]", @@ -269,7 +289,7 @@ 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; + ResourceMark rm(THREAD); 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]",