@@ -2060,7 +2060,7 @@ ClazzLoader.getJ2SLibBase = function () {
2060
2060
if ( idx != - 1 ) {
2061
2061
return src . substring ( 0 , idx ) ;
2062
2062
}
2063
- idx = src . indexOf ( "j2slib.core .js" ) ; // consider it as key string!
2063
+ idx = src . indexOf ( "j2slibcore.z .js" ) ; // consider it as key string!
2064
2064
if ( idx != - 1 ) {
2065
2065
return src . substring ( 0 , idx ) ;
2066
2066
}
@@ -2124,12 +2124,9 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) {
2124
2124
if ( name . indexOf ( swtPkg ) == 0 || name . indexOf ( "$wt" ) == 0 ) {
2125
2125
ClazzLoader . assurePackageClasspath ( swtPkg ) ;
2126
2126
}
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
+ }
2133
2130
2134
2131
/*
2135
2132
* Any ClazzLoader#loadClass calls will be queued until java.* core classes
@@ -2189,11 +2186,14 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) {
2189
2186
}
2190
2187
}
2191
2188
} 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
2197
2197
}
2198
2198
2199
2199
} ;
@@ -2202,7 +2202,7 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) {
2202
2202
* Load the application by the given class name and run its static main method.
2203
2203
*/
2204
2204
/* public */
2205
- $w$ = ClazzLoader . loadAppMain = function ( clazz , args ) {
2205
+ $w$ = ClazzLoader . loadJ2SApp = function ( clazz , args , loaded ) {
2206
2206
if ( clazz == null ) {
2207
2207
return ;
2208
2208
}
@@ -2219,12 +2219,31 @@ $w$ = ClazzLoader.loadAppMain = function (clazz, args) {
2219
2219
if ( agmts == null || ! ( agmts instanceof Array ) ) {
2220
2220
agmts = [ ] ;
2221
2221
}
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 ) {
2223
2240
return function ( ) {
2224
- Clazz . evalType ( clazzName ) . main ( argv ) ;
2241
+ ClazzLoader . loadClass ( "junit.textui.TestRunner" , function ( ) {
2242
+ junit . textui . TestRunner . run ( Clazz . evalType ( clazzName ) ) ;
2243
+ } ) ;
2225
2244
} ;
2226
- } ) ( clazzStr , agmts ) ;
2227
- ClazzLoader . loadClass ( clazzStr , afterLoaded ) ;
2245
+ } ;
2246
+ ClazzLoader . loadJ2SApp ( clazz , args , afterLoaded ) ;
2228
2247
} ;
2229
2248
2230
2249
/* private */
@@ -2368,14 +2387,14 @@ ClazzLoader.destroyClassNode = function (node) {
2368
2387
} ;
2369
2388
2370
2389
/*
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.
2372
2391
*/
2373
2392
window . setTimeout ( function ( ) {
2374
2393
var ss = document . getElementsByTagName ( "SCRIPT" ) ;
2375
2394
for ( var i = 0 ; i < ss . length ; i ++ ) {
2376
2395
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 ) ) {
2379
2398
ClazzLoader . getJ2SLibBase ( ) ; // cached ...
2380
2399
ClazzLoader . removeScriptNode ( ss [ i ] ) ;
2381
2400
break ;
0 commit comments