diff -r 19497b4312bb -r 1376481f15e7 emul/src/main/java/java/lang/AbstractStringBuilder.java --- a/emul/src/main/java/java/lang/AbstractStringBuilder.java Tue Oct 09 11:11:58 2012 -0700 +++ b/emul/src/main/java/java/lang/AbstractStringBuilder.java Tue Oct 16 11:55:56 2012 +0200 @@ -126,7 +126,7 @@ throw new OutOfMemoryError(); newCapacity = Integer.MAX_VALUE; } - value = String.copyOf(value, newCapacity); + value = copyOf(value, newCapacity); } /** @@ -138,7 +138,7 @@ */ public void trimToSize() { if (count < value.length) { - value = String.copyOf(value, count); + value = copyOf(value, count); } } @@ -352,7 +352,7 @@ throw new StringIndexOutOfBoundsException(srcEnd); if (srcBegin > srcEnd) throw new StringIndexOutOfBoundsException("srcBegin > srcEnd"); - String.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin); + arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin); } /** @@ -502,7 +502,7 @@ public AbstractStringBuilder append(char[] str) { int len = str.length; ensureCapacityInternal(count + len); - String.arraycopy(str, 0, value, count, len); + arraycopy(str, 0, value, count, len); count += len; return this; } @@ -532,7 +532,7 @@ public AbstractStringBuilder append(char str[], int offset, int len) { if (len > 0) // let arraycopy report AIOOBE for len < 0 ensureCapacityInternal(count + len); - String.arraycopy(str, offset, value, count, len); + arraycopy(str, offset, value, count, len); count += len; return this; } @@ -699,7 +699,7 @@ throw new StringIndexOutOfBoundsException(); int len = end - start; if (len > 0) { - String.arraycopy(value, start+len, value, start, count-end); + arraycopy(value, start+len, value, start, count-end); count -= len; } return this; @@ -761,7 +761,7 @@ public AbstractStringBuilder deleteCharAt(int index) { if ((index < 0) || (index >= count)) throw new StringIndexOutOfBoundsException(index); - String.arraycopy(value, index+1, value, index, count-index-1); + arraycopy(value, index+1, value, index, count-index-1); count--; return this; } @@ -799,7 +799,7 @@ int newCount = count + len - (end - start); ensureCapacityInternal(newCount); - String.arraycopy(value, end, value, start + len, count - end); + arraycopy(value, end, value, start + len, count - end); str.getChars(value, start); count = newCount; return this; @@ -905,8 +905,8 @@ "offset " + offset + ", len " + len + ", str.length " + str.length); ensureCapacityInternal(count + len); - String.arraycopy(value, index, value, index + len, count - index); - String.arraycopy(str, offset, value, index, len); + arraycopy(value, index, value, index + len, count - index); + arraycopy(str, offset, value, index, len); count += len; return this; } @@ -972,7 +972,7 @@ str = "null"; int len = str.length(); ensureCapacityInternal(count + len); - String.arraycopy(value, offset, value, offset + len, count - offset); + arraycopy(value, offset, value, offset + len, count - offset); str.getChars(value, offset); count += len; return this; @@ -1007,8 +1007,8 @@ throw new StringIndexOutOfBoundsException(offset); int len = str.length; ensureCapacityInternal(count + len); - String.arraycopy(value, offset, value, offset + len, count - offset); - String.arraycopy(str, 0, value, offset, len); + arraycopy(value, offset, value, offset + len, count - offset); + arraycopy(str, 0, value, offset, len); count += len; return this; } @@ -1098,7 +1098,7 @@ + s.length()); int len = end - start; ensureCapacityInternal(count + len); - String.arraycopy(value, dstOffset, value, dstOffset + len, + arraycopy(value, dstOffset, value, dstOffset + len, count - dstOffset); for (int i=start; i " + to); + } + char[] copy = new char[newLength]; + arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); + return copy; + } + + static void arraycopy(char[] value, int srcBegin, char[] dst, int dstBegin, int count) { + while (count-- > 0) { + dst[dstBegin++] = value[srcBegin++]; + } + } + + // access system property + static String getProperty(String nm) { + return null; + } + + static char[] copyOf(char[] original, int newLength) { + char[] copy = new char[newLength]; + arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); + return copy; + } + }