< prev index next >
src/hotspot/share/oops/objArrayKlass.cpp
Print this page
rev 50519 : 8204943: Improve message of ArrayStoreException.
@@ -233,22 +233,38 @@
ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length);
} else {
// slow case: need individual subtype checks
// note: don't use obj_at_put below because it includes a redundant store check
if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) {
- THROW(vmSymbols::java_lang_ArrayStoreException());
+ ResourceMark rm;
+ 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());
}
}
}
}
void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
int dst_pos, int length, TRAPS) {
assert(s->is_objArray(), "must be obj array");
if (!d->is_objArray()) {
- THROW(vmSymbols::java_lang_ArrayStoreException());
+ ResourceMark rm;
+ stringStream ss;
+ ss.print("arraycopy: type mismatch: can not copy object[] into %s[]",
+ type2name_tab[ArrayKlass::cast(d->klass())->element_type()]);
+ 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.
< prev index next >