mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8204943: Improve message of ArrayStoreException
Reviewed-by: lfoltan, hseigel
This commit is contained in:
parent
3a98bd1f53
commit
4a24d95917
6 changed files with 303 additions and 12 deletions
|
@ -235,7 +235,19 @@ void ObjArrayKlass::do_copy(arrayOop s, size_t src_offset,
|
|||
// 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(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 @@ void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
|
|||
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 @@ void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
|
|||
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]",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue