Fix System.arraycopy when the source and dest are the same

This commit is contained in:
Eric Scharff 2007-09-27 15:06:56 -06:00
parent 101b0c3b0e
commit 2ae6aa7ddf
2 changed files with 2 additions and 2 deletions

View File

@ -70,7 +70,7 @@ public class ArrayList<T> implements List<T> {
public void add(int index, T element) {
size = Math.max(size+1, index+1);
grow();
System.arraycopy(array, index, array, index+1, size-index);
System.arraycopy(array, index, array, index+1, size-index-1);
array[index] = element;
}

View File

@ -446,7 +446,7 @@ Java_java_lang_System_arraycopy
{
uint8_t* sbody = &cast<uint8_t>(s, 2 * BytesPerWord);
uint8_t* dbody = &cast<uint8_t>(d, 2 * BytesPerWord);
if (src == dst) {
if (s == d) {
memmove(dbody + (dstOffset * elementSize),
sbody + (srcOffset * elementSize),
length * elementSize);