@@ -366,13 +366,14 @@ Clazz.new_ = function(c, args, cl) {
366366 return f ;
367367}
368368
369- Clazz . newClass = function ( prefix , name , clazz , clazzSuper , interfacez , type ) {
369+ Clazz . newClass = function ( prefix , name , clazz , clazzSuper , interfacez , type ) {
370370 if ( J2S . _debugCore ) {
371371 var qualifiedName = ( prefix ? ( prefix . __PKG_NAME__ || prefix . __CLASS_NAME__ ) + "." : "" ) + name ;
372372 checkDeclared ( qualifiedName , type ) ;
373373 }
374374 clazz || ( clazz = function ( ) { Clazz . newInstance ( this , arguments , 0 , clazz ) } ) ;
375375 clazz . __NAME__ = name ;
376+ prefix . __CLASS_NAME__ && ( clazz . $this$0 = prefix . __CLASS_NAME__ ) ;
376377 clazz . $load$ = [ clazzSuper , interfacez ] ;
377378
378379 // get qualifed name, and for inner classes, the name to use to refer to this
@@ -435,14 +436,13 @@ Clazz.newInstance = function (objThis, args, isInner, clazz) {
435436 } ;
436437 }
437438
438- clazz && clazz . $clinit$ && clazz . $clinit$ ( ) ;
439-
440439 objThis . __JSID__ = ++ _jsid ;
441440
442- clazz && clazz . $init0$ && clazz . $init0$ . apply ( objThis ) ;
443441
444442 if ( ! isInner ) {
445- if ( ( ! args || args . length == 0 ) && objThis . c$ ) {
443+ clazz && clazz . $clinit$ && clazz . $clinit$ ( ) ;
444+ clazz && clazz . $init0$ && clazz . $init0$ . apply ( objThis ) ;
445+ if ( ( ! args || args . length == 0 ) && objThis . c$ ) {
446446 // allow for direct default call "new foo()" to run with its default constructor
447447 objThis . c$ . apply ( objThis ) ;
448448 args && ( args [ 2 ] = Clazz . inheritArgs )
@@ -485,13 +485,13 @@ Clazz.newInstance = function (objThis, args, isInner, clazz) {
485485 isNew = true ;
486486 }
487487 // add all superclass references for outer object
488- var clazz = getClazz ( outerObj ) ;
488+ var clazz1 = getClazz ( outerObj ) ;
489489 do {
490- var key = getClassName ( clazz , true ) ;
490+ var key = getClassName ( clazz1 , true ) ;
491491 if ( ! isNew && b [ key ] )
492492 break ;
493493 b [ key ] = outerObj ;
494- } while ( ( clazz = clazz . superclazz ) ) ;
494+ } while ( ( clazz1 = clazz1 . superclazz ) ) ;
495495 }
496496 // add a flag to disallow any other same-class use of this map.
497497 b [ "$ " + innerName ] = 1 ;
@@ -500,7 +500,9 @@ Clazz.newInstance = function (objThis, args, isInner, clazz) {
500500 outerObj . $b$ = b ;
501501 // final objective: save this map for the inner object
502502 objThis . b$ = b ;
503- objThis . this$0 = outerObj ;
503+ clazz . $this$0 && ( objThis . this$0 = b [ clazz . $this$0 ] ) ;
504+ clazz . $clinit$ && clazz . $clinit$ ( ) ;
505+ clazz . $init0$ && clazz . $init0$ . apply ( objThis ) ;
504506} ;
505507
506508
@@ -1105,18 +1107,18 @@ var extendObject = function(clazz, exclude) {
11051107//};
11061108
11071109var excludeSuper = function ( o ) {
1108- return o == "b$" || o == "this$0"
1110+ return o == "b$" || o == "$ this$0"
11091111 || o == "$init$"
11101112 || o == "$init0$"
11111113 || o == "$clinit$"
11121114 || o == "$load$"
1113- || o == "c$"
11141115 || o == "$Class$"
11151116 || o == "prototype"
11161117 || o == "__CLASS_NAME__"
11171118 || o == "__CLASS_NAME$__"
11181119 || o == "superclazz"
11191120 || o == "implementz"
1121+ || o . startsWith ( "c$" )
11201122}
11211123
11221124var copyStatics = function ( clazzSuper , clazzThis , andProto ) {
@@ -1390,7 +1392,7 @@ var setSuperclass = function(clazzThis, clazzSuper){
13901392 if ( clazzSuper == Number ) {
13911393 clazzThis . prototype = new Number ( ) ;
13921394 } else {
1393- clazzThis . prototype = new clazzSuper ( null , inheritArgs ) ;
1395+ clazzThis . prototype = new clazzSuper ( [ inheritArgs ] ) ;
13941396 if ( clazzSuper == Error ) {
13951397 var pp = Throwable . prototype ;
13961398 for ( o in pp ) {
@@ -2056,8 +2058,12 @@ Clazz.loadScript = function(file) {
20562058 s = data ;
20572059 if ( s . indexOf ( "missing ] after element list" ) >= 0 )
20582060 s = "File not found" ;
2059- doDebugger ( )
2060- alert ( s + " loading file " + file ) ;
2061+ if ( file . indexOf ( "/j2s/core/" ) >= 0 ) {
2062+ System . out . println ( s + " loading " + file ) ;
2063+ } else {
2064+ doDebugger ( )
2065+ alert ( s + " loading file " + file ) ;
2066+ }
20612067 }
20622068}
20632069
0 commit comments