233 ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length); |
233 ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length); |
234 } else { |
234 } else { |
235 // slow case: need individual subtype checks |
235 // slow case: need individual subtype checks |
236 // note: don't use obj_at_put below because it includes a redundant store check |
236 // note: don't use obj_at_put below because it includes a redundant store check |
237 if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) { |
237 if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) { |
238 THROW(vmSymbols::java_lang_ArrayStoreException()); |
238 ResourceMark rm(THREAD); |
|
239 stringStream ss; |
|
240 if (!bound->is_subtype_of(stype)) { |
|
241 ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]", |
|
242 stype->external_name(), bound->external_name()); |
|
243 } else { |
|
244 // oop_arraycopy should return the index in the source array that |
|
245 // contains the problematic oop. |
|
246 ss.print("arraycopy: element type mismatch: can not cast one of the elements" |
|
247 " of %s[] to the type of the destination array, %s", |
|
248 stype->external_name(), bound->external_name()); |
|
249 } |
|
250 THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); |
239 } |
251 } |
240 } |
252 } |
241 } |
253 } |
242 } |
254 } |
243 |
255 |
244 void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, |
256 void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, |
245 int dst_pos, int length, TRAPS) { |
257 int dst_pos, int length, TRAPS) { |
246 assert(s->is_objArray(), "must be obj array"); |
258 assert(s->is_objArray(), "must be obj array"); |
247 |
259 |
248 if (!d->is_objArray()) { |
260 if (!d->is_objArray()) { |
249 THROW(vmSymbols::java_lang_ArrayStoreException()); |
261 ResourceMark rm(THREAD); |
|
262 stringStream ss; |
|
263 if (d->is_typeArray()) { |
|
264 ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]", |
|
265 type2name_tab[ArrayKlass::cast(d->klass())->element_type()]); |
|
266 } else { |
|
267 ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name()); |
|
268 } |
|
269 THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); |
250 } |
270 } |
251 |
271 |
252 // Check is all offsets and lengths are non negative |
272 // Check is all offsets and lengths are non negative |
253 if (src_pos < 0 || dst_pos < 0 || length < 0) { |
273 if (src_pos < 0 || dst_pos < 0 || length < 0) { |
254 // Pass specific exception reason. |
274 // Pass specific exception reason. |
255 ResourceMark rm; |
275 ResourceMark rm(THREAD); |
256 stringStream ss; |
276 stringStream ss; |
257 if (src_pos < 0) { |
277 if (src_pos < 0) { |
258 ss.print("arraycopy: source index %d out of bounds for object array[%d]", |
278 ss.print("arraycopy: source index %d out of bounds for object array[%d]", |
259 src_pos, s->length()); |
279 src_pos, s->length()); |
260 } else if (dst_pos < 0) { |
280 } else if (dst_pos < 0) { |
267 } |
287 } |
268 // Check if the ranges are valid |
288 // Check if the ranges are valid |
269 if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) || |
289 if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) || |
270 (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) { |
290 (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) { |
271 // Pass specific exception reason. |
291 // Pass specific exception reason. |
272 ResourceMark rm; |
292 ResourceMark rm(THREAD); |
273 stringStream ss; |
293 stringStream ss; |
274 if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) { |
294 if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) { |
275 ss.print("arraycopy: last source index %u out of bounds for object array[%d]", |
295 ss.print("arraycopy: last source index %u out of bounds for object array[%d]", |
276 (unsigned int) length + (unsigned int) src_pos, s->length()); |
296 (unsigned int) length + (unsigned int) src_pos, s->length()); |
277 } else { |
297 } else { |