Removing package private String constructor which used to be used by Integer and Long to share the char array with newly created string
1.1 --- a/emul/src/main/java/java/lang/Integer.java Sun Nov 18 08:41:08 2012 +0100
1.2 +++ b/emul/src/main/java/java/lang/Integer.java Sun Nov 18 08:51:58 2012 +0100
1.3 @@ -324,13 +324,14 @@
1.4 * @param i an integer to be converted.
1.5 * @return a string representation of the argument in base 10.
1.6 */
1.7 + @JavaScriptBody(args = "i", body = "return i.toString();")
1.8 public static String toString(int i) {
1.9 if (i == Integer.MIN_VALUE)
1.10 return "-2147483648";
1.11 int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
1.12 char[] buf = new char[size];
1.13 getChars(i, size, buf);
1.14 - return new String(0, size, buf);
1.15 + return new String(buf, 0, size);
1.16 }
1.17
1.18 /**
2.1 --- a/emul/src/main/java/java/lang/Long.java Sun Nov 18 08:41:08 2012 +0100
2.2 +++ b/emul/src/main/java/java/lang/Long.java Sun Nov 18 08:51:58 2012 +0100
2.3 @@ -25,6 +25,8 @@
2.4
2.5 package java.lang;
2.6
2.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
2.8 +
2.9 /**
2.10 * The {@code Long} class wraps a value of the primitive type {@code
2.11 * long} in an object. An object of type {@code Long} contains a
2.12 @@ -260,13 +262,14 @@
2.13 * @param i a {@code long} to be converted.
2.14 * @return a string representation of the argument in base 10.
2.15 */
2.16 + @JavaScriptBody(args = "i", body = "return i.toString();")
2.17 public static String toString(long i) {
2.18 if (i == Long.MIN_VALUE)
2.19 return "-9223372036854775808";
2.20 int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
2.21 char[] buf = new char[size];
2.22 getChars(i, size, buf);
2.23 - return new String(0, size, buf);
2.24 + return new String(buf, 0, size);
2.25 }
2.26
2.27 /**
3.1 --- a/emul/src/main/java/java/lang/String.java Sun Nov 18 08:41:08 2012 +0100
3.2 +++ b/emul/src/main/java/java/lang/String.java Sun Nov 18 08:51:58 2012 +0100
3.3 @@ -641,14 +641,6 @@
3.4 this.offset = result.offset;
3.5 }
3.6
3.7 -
3.8 - // Package private constructor which shares value array for speed.
3.9 - String(int offset, int count, char value[]) {
3.10 - this.value = value;
3.11 - this.offset = offset;
3.12 - this.count = count;
3.13 - }
3.14 -
3.15 /**
3.16 * Returns the length of this string.
3.17 * The length is equal to the number of <a href="Character.html#unicode">Unicode
3.18 @@ -1966,7 +1958,7 @@
3.19 throw new StringIndexOutOfBoundsException(endIndex - beginIndex);
3.20 }
3.21 return ((beginIndex == 0) && (endIndex == count)) ? this :
3.22 - new String(offset + beginIndex, endIndex - beginIndex, value);
3.23 + new String(value, offset + beginIndex, endIndex - beginIndex);
3.24 }
3.25
3.26 /**
3.27 @@ -2029,7 +2021,7 @@
3.28 char buf[] = new char[count + otherLen];
3.29 getChars(0, count, buf, 0);
3.30 str.getChars(0, otherLen, buf, count);
3.31 - return new String(0, count + otherLen, buf);
3.32 + return new String(buf, 0, count + otherLen);
3.33 }
3.34
3.35 /**
3.36 @@ -2083,7 +2075,7 @@
3.37 buf[i] = (c == oldChar) ? newChar : c;
3.38 i++;
3.39 }
3.40 - return new String(0, len, buf);
3.41 + return new String(buf, 0, len);
3.42 }
3.43 }
3.44 return this;
3.45 @@ -2951,7 +2943,7 @@
3.46 */
3.47 public static String valueOf(char c) {
3.48 char data[] = {c};
3.49 - return new String(0, 1, data);
3.50 + return new String(data, 0, 1);
3.51 }
3.52
3.53 /**