< prev index next >

src/hotspot/share/oops/typeArrayKlass.cpp

Print this page
rev 50027 : 8201593: Print array length in ArrayIndexOutOfBoundsException.
Reviewed-by: dholmes, mdoerr, smonteith, shade

*** 136,151 **** 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()); } // Check zero copy if (length == 0) return; --- 136,175 ---- 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 %s[%i]", ! src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length()); ! } else if (dst_pos < 0) { ! ss.print("arraycopy: destination index %i out of bounds for %s[%i]", ! dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], 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 %s[%i]", ! (unsigned int) length + (unsigned int) src_pos, ! type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length()); ! } else { ! ss.print("arraycopy: last destination index %u out of bounds for %s[%i]", ! (unsigned int) length + (unsigned int) dst_pos, ! type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length()); ! } ! THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); } // Check zero copy if (length == 0) return;
*** 155,165 **** void* src = (char*) (s->base(element_type())) + ((size_t)src_pos << l2es); void* dst = (char*) (d->base(element_type())) + ((size_t)dst_pos << l2es); HeapAccess<ARRAYCOPY_ATOMIC>::arraycopy(s, d, src, dst, (size_t)length << l2es); } - // create a klass of array holding typeArrays Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { int dim = dimension(); assert(dim <= n, "check order of chain"); if (dim == n) --- 179,188 ----
*** 238,257 **** } void TypeArrayKlass::print_value_on(outputStream* st) const { assert(is_klass(), "must be klass"); st->print("{type array "); ! switch (element_type()) { ! case T_BOOLEAN: st->print("bool"); break; ! case T_CHAR: st->print("char"); break; ! case T_FLOAT: st->print("float"); break; ! case T_DOUBLE: st->print("double"); break; ! case T_BYTE: st->print("byte"); break; ! case T_SHORT: st->print("short"); break; ! case T_INT: st->print("int"); break; ! case T_LONG: st->print("long"); break; ! default: ShouldNotReachHere(); } st->print("}"); } #ifndef PRODUCT --- 261,275 ---- } void TypeArrayKlass::print_value_on(outputStream* st) const { assert(is_klass(), "must be klass"); st->print("{type array "); ! BasicType bt = element_type(); ! if (bt == T_BOOLEAN) { ! st->print("bool"); ! } else { ! st->print("%s", type2name_tab[bt]); } st->print("}"); } #ifndef PRODUCT
< prev index next >