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
140 if (src_pos < 0 || dst_pos < 0 || length < 0) {
141 // Pass specific exception reason.
142 ResourceMark rm;
143 stringStream ss;
144 if (src_pos < 0) {
145 ss.print("arraycopy: source index %d out of bounds for %s[%d]",
146 src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length());
147 } else if (dst_pos < 0) {
148 ss.print("arraycopy: destination index %d out of bounds for %s[%d]",
149 dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length());
150 } else {
151 ss.print("arraycopy: length %d is negative", length);
152 }
153 THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
154 }
155 // Check if the ranges are valid
156 if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) ||
|
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 ResourceMark rm;
137 stringStream ss;
138 ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]",
139 type2name_tab[ArrayKlass::cast(s->klass())->element_type()],
140 type2name_tab[ArrayKlass::cast(d->klass())->element_type()]);
141 THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string());
142 }
143
144 // Check is all offsets and lengths are non negative
145 if (src_pos < 0 || dst_pos < 0 || length < 0) {
146 // Pass specific exception reason.
147 ResourceMark rm;
148 stringStream ss;
149 if (src_pos < 0) {
150 ss.print("arraycopy: source index %d out of bounds for %s[%d]",
151 src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length());
152 } else if (dst_pos < 0) {
153 ss.print("arraycopy: destination index %d out of bounds for %s[%d]",
154 dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length());
155 } else {
156 ss.print("arraycopy: length %d is negative", length);
157 }
158 THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
159 }
160 // Check if the ranges are valid
161 if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) ||
|