Skip to content

Commit c41d2c0

Browse files
committed
// BH 2019.12.29 3.2.6 fixes Float.parseFloat$S("NaN") [and Double]
better, but not perfect, primitive TYPE class methods.
1 parent 59729f7 commit c41d2c0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

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

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

10+
// BH 2019.12.29 3.2.6 fixes Float.parseFloat$S("NaN") [and Double]
1011
// BH 2019.12.23 3.2.6 update of System
1112
// BH 2019.12.19 3.2.6 revision of $clinit$
1213
// BH 2019.12.16 3.2.5.v4 adds ClassLoader static methods for system resources (just j2s/...)
@@ -66,7 +67,7 @@ Clazz.ClassFilesLoaded = [];
6667
Clazz.popup = Clazz.log = Clazz.error = window.alert;
6768

6869
/* can be set by page JavaScript */
69-
Clazz.defaultAssertionStatus = true;
70+
Clazz.defaultAssertionStatus = false;
7071

7172
/* can be set by page JavaScript */
7273
Clazz._assertFunction = null;
@@ -3459,6 +3460,8 @@ if (typeof arguments[0] != "object")this.c$(arguments[0]);
34593460
var primTypes = {};
34603461

34613462
var FALSE = function() { return false };
3463+
var EMPTY_CLASSES = function() {return Clazz.array(Class, [0])};
3464+
var NULL_FUNC = function() {return null};
34623465

34633466
var setJ2STypeclass = function(cl, type, paramCode) {
34643467
// TODO -- should be a proper Java.lang.Class
@@ -3473,6 +3476,8 @@ var setJ2STypeclass = function(cl, type, paramCode) {
34733476
cl.TYPE.toString = cl.TYPE.getName$ = cl.TYPE.getTypeName$
34743477
= cl.TYPE.getCanonicalName$ = cl.TYPE.getSimpleName$ = function() {return type};
34753478
cl.TYPE.isAssignableFrom$Class = (function(t) {return function(c) {return c == t}})(cl.TYPE);
3479+
cl.TYPE.getSuperclass$ = NULL_FUNC;
3480+
cl.TYPE.getInterfaces$ = EMPTY_CLASSES;
34763481
}
34773482

34783483
var decorateAsNumber = function (clazz, qClazzName, type, PARAMCODE) {
@@ -3906,6 +3911,8 @@ if(s==null){
39063911
throw Clazz.new_(NumberFormatException.c$$S, ["null"]);
39073912
}
39083913
if (typeof s == "number")return s; // important -- typeof NaN is "number" and is OK here
3914+
if (s == "NaN")
3915+
return NaN;
39093916
var floatVal=Number(s);
39103917
if(isNaN(floatVal)){
39113918
throw Clazz.new_(NumberFormatException.c$$S, ["Not a Number : "+s]);
@@ -3978,6 +3985,8 @@ if(s==null){
39783985
throw Clazz.new_(NumberFormatException.c$$S, ["null"]);
39793986
}
39803987
if (typeof s == "number")return s; // important -- typeof NaN is "number" and is OK here
3988+
if (s == "NaN")
3989+
return NaN;
39813990
var doubleVal=Number(s);
39823991
if(isNaN(doubleVal)){
39833992
throw Clazz.new_(NumberFormatException.c$$S, ["Not a Number : "+s]);

0 commit comments

Comments
 (0)