diff --git a/classpath/java/util/ArrayList.java b/classpath/java/util/ArrayList.java index fa0813805c..abb5ea28cc 100644 --- a/classpath/java/util/ArrayList.java +++ b/classpath/java/util/ArrayList.java @@ -70,7 +70,7 @@ public class ArrayList implements List { 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; } diff --git a/src/builtin.cpp b/src/builtin.cpp index 44209e5f4c..a9a84e8fdf 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -446,7 +446,7 @@ Java_java_lang_System_arraycopy { uint8_t* sbody = &cast(s, 2 * BytesPerWord); uint8_t* dbody = &cast(d, 2 * BytesPerWord); - if (src == dst) { + if (s == d) { memmove(dbody + (dstOffset * elementSize), sbody + (srcOffset * elementSize), length * elementSize);