From 2ae6aa7ddf694cac9c56ce99777d6ab529872f1d Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Thu, 27 Sep 2007 15:06:56 -0600 Subject: [PATCH] Fix System.arraycopy when the source and dest are the same --- classpath/java/util/ArrayList.java | 2 +- src/builtin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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);