@@ -2060,7 +2060,7 @@ ClazzLoader.getJ2SLibBase = function () {
20602060 if ( idx != - 1 ) {
20612061 return src . substring ( 0 , idx ) ;
20622062 }
2063- idx = src . indexOf ( "j2slib.core .js" ) ; // consider it as key string!
2063+ idx = src . indexOf ( "j2slibcore.z .js" ) ; // consider it as key string!
20642064 if ( idx != - 1 ) {
20652065 return src . substring ( 0 , idx ) ;
20662066 }
@@ -2124,12 +2124,9 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) {
21242124 if ( name . indexOf ( swtPkg ) == 0 || name . indexOf ( "$wt" ) == 0 ) {
21252125 ClazzLoader . assurePackageClasspath ( swtPkg ) ;
21262126 }
2127- /*
2128- * "junit" is not considered as inner supported library.
2129- */
2130- //if (name.indexOf ("junit") == 0) {
2131- // ClazzLoader.assurePackageClasspath ("junit");
2132- //}
2127+ if ( name . indexOf ( "junit" ) == 0 ) {
2128+ ClazzLoader . assurePackageClasspath ( "junit" ) ;
2129+ }
21332130
21342131 /*
21352132 * Any ClazzLoader#loadClass calls will be queued until java.* core classes
@@ -2189,11 +2186,14 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) {
21892186 }
21902187 }
21912188 } else if ( optionalsLoaded != null && ClazzLoader . isClassDefined ( name ) ) {
2192- if ( async ) {
2193- window . setTimeout ( optionalsLoaded , 25 ) ;
2194- } else {
2195- optionalsLoaded ( ) ;
2196- }
2189+ var nn = ClazzLoader . findClass ( name ) ;
2190+ if ( nn == null || nn . status >= ClazzNode . STATUS_OPTIONALS_LOADED ) {
2191+ if ( async ) {
2192+ window . setTimeout ( optionalsLoaded , 25 ) ;
2193+ } else {
2194+ optionalsLoaded ( ) ;
2195+ }
2196+ } // else ... should be called later
21972197 }
21982198
21992199} ;
@@ -2202,7 +2202,7 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) {
22022202 * Load the application by the given class name and run its static main method.
22032203 */
22042204/* public */
2205- $w$ = ClazzLoader . loadAppMain = function ( clazz , args ) {
2205+ $w$ = ClazzLoader . loadJ2SApp = function ( clazz , args , loaded ) {
22062206 if ( clazz == null ) {
22072207 return ;
22082208 }
@@ -2219,12 +2219,31 @@ $w$ = ClazzLoader.loadAppMain = function (clazz, args) {
22192219 if ( agmts == null || ! ( agmts instanceof Array ) ) {
22202220 agmts = [ ] ;
22212221 }
2222- var afterLoaded = ( function ( clazzName , argv ) {
2222+ var afterLoaded = loaded ;
2223+ if ( afterLoaded == null ) {
2224+ afterLoaded = ( function ( clazzName , argv ) {
2225+ return function ( ) {
2226+ Clazz . evalType ( clazzName ) . main ( argv ) ;
2227+ } ;
2228+ } ) ( clazzStr , agmts ) ;
2229+ } else {
2230+ afterLoaded = loaded ( clazzStr , agmts ) ;
2231+ }
2232+ ClazzLoader . loadClass ( clazzStr , afterLoaded ) ;
2233+ } ;
2234+ /**
2235+ * Load JUnit tests by the given class name.
2236+ */
2237+ /* public */
2238+ $u$ = ClazzLoader . loadJUnit = function ( clazz , args ) {
2239+ var afterLoaded = function ( clazzName , argv ) {
22232240 return function ( ) {
2224- Clazz . evalType ( clazzName ) . main ( argv ) ;
2241+ ClazzLoader . loadClass ( "junit.textui.TestRunner" , function ( ) {
2242+ junit . textui . TestRunner . run ( Clazz . evalType ( clazzName ) ) ;
2243+ } ) ;
22252244 } ;
2226- } ) ( clazzStr , agmts ) ;
2227- ClazzLoader . loadClass ( clazzStr , afterLoaded ) ;
2245+ } ;
2246+ ClazzLoader . loadJ2SApp ( clazz , args , afterLoaded ) ;
22282247} ;
22292248
22302249/* private */
@@ -2368,14 +2387,14 @@ ClazzLoader.destroyClassNode = function (node) {
23682387} ;
23692388
23702389/*
2371- * Remove j2slib.z.js, j2slib.core .js or Class/Ext/Loader/.js.
2390+ * Remove j2slib.z.js, j2slibcore.z .js or Class/Ext/Loader/.js.
23722391 */
23732392window . setTimeout ( function ( ) {
23742393 var ss = document . getElementsByTagName ( "SCRIPT" ) ;
23752394 for ( var i = 0 ; i < ss . length ; i ++ ) {
23762395 var src = ss [ i ] . src ;
2377- if ( ( src . indexOf ( "j2slib.z.js" ) != - 1 )
2378- || ( src . indexOf ( "j2slib.core .js" ) != - 1 ) ) {
2396+ if ( src . indexOf ( "chrome:" ) != 0 && ( src . indexOf ( "j2slib.z.js" ) != - 1
2397+ || src . indexOf ( "j2slibcore.z .js" ) != - 1 ) ) {
23792398 ClazzLoader . getJ2SLibBase ( ) ; // cached ...
23802399 ClazzLoader . removeScriptNode ( ss [ i ] ) ;
23812400 break ;
0 commit comments