# HG changeset patch # User Jaroslav Tulach # Date 1353225118 -3600 # Node ID 469199c2994a941dc5b267a162f7e941f3254d7c # Parent 28143312edb5ce60404af06dc1033d9098425e45 Removing package private String constructor which used to be used by Integer and Long to share the char array with newly created string diff -r 28143312edb5 -r 469199c2994a emul/src/main/java/java/lang/Integer.java --- a/emul/src/main/java/java/lang/Integer.java Sun Nov 18 08:41:08 2012 +0100 +++ b/emul/src/main/java/java/lang/Integer.java Sun Nov 18 08:51:58 2012 +0100 @@ -324,13 +324,14 @@ * @param i an integer to be converted. * @return a string representation of the argument in base 10. */ + @JavaScriptBody(args = "i", body = "return i.toString();") public static String toString(int i) { if (i == Integer.MIN_VALUE) return "-2147483648"; int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); char[] buf = new char[size]; getChars(i, size, buf); - return new String(0, size, buf); + return new String(buf, 0, size); } /** diff -r 28143312edb5 -r 469199c2994a emul/src/main/java/java/lang/Long.java --- a/emul/src/main/java/java/lang/Long.java Sun Nov 18 08:41:08 2012 +0100 +++ b/emul/src/main/java/java/lang/Long.java Sun Nov 18 08:51:58 2012 +0100 @@ -25,6 +25,8 @@ package java.lang; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + /** * The {@code Long} class wraps a value of the primitive type {@code * long} in an object. An object of type {@code Long} contains a @@ -260,13 +262,14 @@ * @param i a {@code long} to be converted. * @return a string representation of the argument in base 10. */ + @JavaScriptBody(args = "i", body = "return i.toString();") public static String toString(long i) { if (i == Long.MIN_VALUE) return "-9223372036854775808"; int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); char[] buf = new char[size]; getChars(i, size, buf); - return new String(0, size, buf); + return new String(buf, 0, size); } /** diff -r 28143312edb5 -r 469199c2994a emul/src/main/java/java/lang/String.java --- a/emul/src/main/java/java/lang/String.java Sun Nov 18 08:41:08 2012 +0100 +++ b/emul/src/main/java/java/lang/String.java Sun Nov 18 08:51:58 2012 +0100 @@ -641,14 +641,6 @@ this.offset = result.offset; } - - // Package private constructor which shares value array for speed. - String(int offset, int count, char value[]) { - this.value = value; - this.offset = offset; - this.count = count; - } - /** * Returns the length of this string. * The length is equal to the number of Unicode @@ -1966,7 +1958,7 @@ throw new StringIndexOutOfBoundsException(endIndex - beginIndex); } return ((beginIndex == 0) && (endIndex == count)) ? this : - new String(offset + beginIndex, endIndex - beginIndex, value); + new String(value, offset + beginIndex, endIndex - beginIndex); } /** @@ -2029,7 +2021,7 @@ char buf[] = new char[count + otherLen]; getChars(0, count, buf, 0); str.getChars(0, otherLen, buf, count); - return new String(0, count + otherLen, buf); + return new String(buf, 0, count + otherLen); } /** @@ -2083,7 +2075,7 @@ buf[i] = (c == oldChar) ? newChar : c; i++; } - return new String(0, len, buf); + return new String(buf, 0, len); } } return this; @@ -2951,7 +2943,7 @@ */ public static String valueOf(char c) { char data[] = {c}; - return new String(0, 1, data); + return new String(data, 0, 1); } /**