Skip to content

Commit 78260e5

Browse files
committed
errant "if(args)" in newInstance just introduced
1 parent 20532a6 commit 78260e5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
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.11.26 3.2.5.v1 errant if (args) in newInstance
1011
// BH 2019.11.07 3.2.5.v0 full encapsulation
1112
// BH 2019.11.07 3.2.5.v0 adds encapsulation for window
1213
// BH 2019.11.07 3.2.5.v0 splitting off $static$ from $clinit$ (see Java2ScriptVisitor notes)
@@ -464,13 +465,15 @@ Clazz.new_ = function(c, args, cl) {
464465
// Integer will be passed as is here, without c.exClazz, or cl
465466
var clInner = cl;
466467
cl = cl || c.exClazz || c;
467-
Clazz._initClass(cl,1,0,0); // critical here; next will call (0,1,0)
468+
Clazz._initClass(cl,1,0,0);
469+
// BH note: Critical here that the above is not 1,1,0;
470+
// static init is the responsibility of newInstance
471+
// or a static field or method call (which is handled
472+
// by the $I$(n) handler in the function initializer in
473+
// the newClass() call.
468474
var obj = new (Function.prototype.bind.apply(cl, arguments));
469475
if (args[2] != inheritArgs) {
470-
if (haveArgs) {
471-
// Clazz._initClass(cl,0,1,0);
472-
c.apply(obj, args);
473-
}
476+
haveArgs && c.apply(obj, args);
474477
clInner && clInner.$init$.apply(obj);
475478
}
476479

@@ -563,7 +566,7 @@ Clazz.newInstance = function (objThis, args, isInner, clazz) {
563566
objThis.__JSID__ = ++_jsid;
564567

565568
if (!isInner) {
566-
if (args)
569+
// if (args)
567570
clazz && Clazz._initClass(clazz,1,1,objThis);
568571
if ((!args || args.length == 0) && objThis.c$) {
569572
// allow for direct default call "new foo()" to run with its default constructor

0 commit comments

Comments
 (0)