@@ -304,6 +304,8 @@ static public void addURL(Object url) throws MalformedURLException{
304
304
throw new IllegalAccessError ("Context classloader is not a DynamicClassLoader" );
305
305
}
306
306
307
+ static IPersistentSet loadedPaths = set ();
308
+
307
309
static {
308
310
Keyword arglistskw = Keyword .intern (null , "arglists" );
309
311
Symbol namesym = Symbol .intern ("name" );
@@ -440,7 +442,10 @@ static public void load(String scriptbase, boolean failIfNotFound) throws IOExce
440
442
RT .mapUniqueKeys (CURRENT_NS , CURRENT_NS .deref (),
441
443
WARN_ON_REFLECTION , WARN_ON_REFLECTION .deref ()
442
444
,RT .UNCHECKED_MATH , RT .UNCHECKED_MATH .deref ()));
443
- loaded = (loadClassForName (scriptbase .replace ('/' , '.' ) + LOADER_SUFFIX ) != null );
445
+ String className = scriptbase .replace ('/' , '.' ) + LOADER_SUFFIX ;
446
+ loaded = (classForNameNonLoadingSafe (className ) != null );
447
+ if (loaded && !loadedPaths .contains (scriptbase ))
448
+ loadClassForName (className );
444
449
}
445
450
finally {
446
451
Var .popThreadBindings ();
@@ -451,10 +456,13 @@ static public void load(String scriptbase, boolean failIfNotFound) throws IOExce
451
456
compile (scriptfile );
452
457
else
453
458
loadResourceScript (RT .class , scriptfile );
459
+ loaded = true ;
454
460
}
455
461
else if (!loaded && failIfNotFound )
456
462
throw new FileNotFoundException (String .format ("Could not locate %s or %s on classpath.%s" , classfile , cljfile ,
457
463
scriptbase .contains ("_" ) ? " Please check that namespaces with dashes use underscores in the Clojure file name." : "" ));
464
+ if (loaded )
465
+ loadedPaths = (IPersistentSet ) loadedPaths .cons (scriptbase );
458
466
}
459
467
460
468
static void doInit () throws ClassNotFoundException , IOException {
@@ -2187,10 +2195,10 @@ static public Class classForNameNonLoading(String name) {
2187
2195
return classForName (name , false , baseLoader ());
2188
2196
}
2189
2197
2190
- static public Class loadClassForName (String name ) {
2198
+ static public Class classForNameNonLoadingSafe (String name ) {
2191
2199
try
2192
2200
{
2193
- classForNameNonLoading (name );
2201
+ return classForNameNonLoading (name );
2194
2202
}
2195
2203
catch (Exception e )
2196
2204
{
@@ -2199,7 +2207,12 @@ static public Class loadClassForName(String name) {
2199
2207
else
2200
2208
throw Util .sneakyThrow (e );
2201
2209
}
2202
- return classForName (name );
2210
+ }
2211
+
2212
+ static public Class loadClassForName (String name ) {
2213
+ if (classForNameNonLoadingSafe (name ) == null )
2214
+ return null ;
2215
+ return classForName (name );
2203
2216
}
2204
2217
2205
2218
static public float aget (float [] xs , int i ){
0 commit comments