< prev index next >

src/hotspot/share/oops/typeArrayKlass.cpp

Print this page
rev 49827 : 8201593: Print array length in ArrayIndexOutOfBoundsException.

*** 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,177 ---- 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("while trying to copy from index %i of a %s array with length %i", ! src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length()); ! } else if (dst_pos < 0) { ! ss.print("while trying to copy to index %i of a %s array with length %i", ! dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length()); ! } else { ! ss.print("while trying to copy a negative range %i from a %s array with length %i to a %s array with length %i", ! length, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length(), ! type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->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("while trying to copy from index %u of a %s array with length %i", ! (unsigned int) length + (unsigned int) src_pos, ! type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length()); ! } else { ! ss.print("while trying to copy to index %u of a %s array with length %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) --- 181,190 ----
*** 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 --- 263,277 ---- } 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 >