Skip to content

Commit a6430e1

Browse files
committed
fixes new String("xxx") and "xxx" needs to be distinction
1 parent de603a6 commit a6430e1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
// Google closure compiler cannot handle Clazz.new or Clazz.super
99

10-
// BH 2020.03.11 2.3.9-v1 fixes numerous subtle issues with boxed primatives Integer, Float, etc.
11-
// BH 2020.03.07 2.3.9-v1 fixes array.hashCode() to be System.identityHashCode(array).
12-
// BH 2020.02.18 2.3.8-v2 upgrades String, Integer, ClassLoader, Package, various Exceptions
10+
// BH 2020.03.19 3.2.9-v1c fixes new String("xxx") !== "xxx"
11+
// BH 2020.03.11 3.2.9-v1b fixes numerous subtle issues with boxed primatives Integer, Float, etc.
12+
// BH 2020.03.07 3.2.9-v1a fixes array.hashCode() to be System.identityHashCode(array).
13+
// BH 2020.02.18 3.2.8-v2 upgrades String, Integer, ClassLoader, Package, various Exceptions
1314
// BH 2020.02.12 3.2.8-v1 new Throwable().getStackTrace() should not include j2sClazz methods
1415
// BH 2020.02.02 3.2.7-v5 fixes array.getClass().getName() and getArrayClass() for short -- should be [S, not [H, for Java
1516
// BH 2019.12.29 3.2.6 fixes Float.parseFloat$S("NaN") [and Double]
@@ -3200,7 +3201,7 @@ C$.arraycopy$O$I$O$I$I=function (src, srcPos, dest, destPos, length) {
32003201
}
32013202

32023203
C$.identityHashCode$O=function (x, offset) {
3203-
return x==null ? 0 : x._$hashcode || (x._$hashcode = ++hashCode + (offset || 0));
3204+
return x==null ? 0 : x._$hashcode || (typeof x == "string" ? x.hashCode$() : (x._$hashcode = ++hashCode + (offset || 0)));
32043205
}
32053206

32063207
C$.getProperties$=function () {
@@ -4933,9 +4934,9 @@ case 1:
49334934
// String(StringBuilder builder)
49344935
// String(String original)
49354936
if (x.__BYTESIZE || x instanceof Array){
4936-
return (x.length == 0 ? "" : typeof x[0]=="number" ? Encoding.readUTF8Array(x) : x.join(''));
4937+
return new String(x.length == 0 ? "" : typeof x[0]=="number" ? Encoding.readUTF8Array(x) : x.join(''));
49374938
}
4938-
return x.toString();
4939+
return new String(x.toString());
49394940
case 2:
49404941
// String(char[] value, boolean share)
49414942
// String(byte[] ascii, int hibyte)

0 commit comments

Comments
 (0)