< prev index next >

src/hotspot/share/oops/typeArrayKlass.cpp

Print this page
rev 50282 : 8203881: Print erroneous size in NegativeArraySizeException


  99 
 100 typeArrayOop TypeArrayKlass::allocate_common(int length, bool do_zero, TRAPS) {
 101   assert(log2_element_size() >= 0, "bad scale");
 102   if (length >= 0) {
 103     if (length <= max_length()) {
 104       size_t size = typeArrayOopDesc::object_size(layout_helper(), length);
 105       typeArrayOop t;
 106       CollectedHeap* ch = Universe::heap();
 107       if (do_zero) {
 108         t = (typeArrayOop)CollectedHeap::array_allocate(this, (int)size, length, CHECK_NULL);
 109       } else {
 110         t = (typeArrayOop)CollectedHeap::array_allocate_nozero(this, (int)size, length, CHECK_NULL);
 111       }
 112       return t;
 113     } else {
 114       report_java_out_of_memory("Requested array size exceeds VM limit");
 115       JvmtiExport::post_array_size_exhausted();
 116       THROW_OOP_0(Universe::out_of_memory_error_array_size());
 117     }
 118   } else {
 119     THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
 120   }
 121 }
 122 
 123 oop TypeArrayKlass::multi_allocate(int rank, jint* last_size, TRAPS) {
 124   // For typeArrays this is only called for the last dimension
 125   assert(rank == 1, "just checking");
 126   int length = *last_size;
 127   return allocate(length, THREAD);
 128 }
 129 
 130 
 131 void TypeArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {
 132   assert(s->is_typeArray(), "must be type array");
 133 
 134   // Check destination
 135   if (!d->is_typeArray() || element_type() != TypeArrayKlass::cast(d->klass())->element_type()) {
 136     THROW(vmSymbols::java_lang_ArrayStoreException());
 137   }
 138 
 139   // Check is all offsets and lengths are non negative




  99 
 100 typeArrayOop TypeArrayKlass::allocate_common(int length, bool do_zero, TRAPS) {
 101   assert(log2_element_size() >= 0, "bad scale");
 102   if (length >= 0) {
 103     if (length <= max_length()) {
 104       size_t size = typeArrayOopDesc::object_size(layout_helper(), length);
 105       typeArrayOop t;
 106       CollectedHeap* ch = Universe::heap();
 107       if (do_zero) {
 108         t = (typeArrayOop)CollectedHeap::array_allocate(this, (int)size, length, CHECK_NULL);
 109       } else {
 110         t = (typeArrayOop)CollectedHeap::array_allocate_nozero(this, (int)size, length, CHECK_NULL);
 111       }
 112       return t;
 113     } else {
 114       report_java_out_of_memory("Requested array size exceeds VM limit");
 115       JvmtiExport::post_array_size_exhausted();
 116       THROW_OOP_0(Universe::out_of_memory_error_array_size());
 117     }
 118   } else {
 119     THROW_MSG_0(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", length));
 120   }
 121 }
 122 
 123 oop TypeArrayKlass::multi_allocate(int rank, jint* last_size, TRAPS) {
 124   // For typeArrays this is only called for the last dimension
 125   assert(rank == 1, "just checking");
 126   int length = *last_size;
 127   return allocate(length, THREAD);
 128 }
 129 
 130 
 131 void TypeArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {
 132   assert(s->is_typeArray(), "must be type array");
 133 
 134   // Check destination
 135   if (!d->is_typeArray() || element_type() != TypeArrayKlass::cast(d->klass())->element_type()) {
 136     THROW(vmSymbols::java_lang_ArrayStoreException());
 137   }
 138 
 139   // Check is all offsets and lengths are non negative


< prev index next >