Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit 80d8653

Browse files
Multiple AOT-namespaces bug fix
1 parent 6a4fc57 commit 80d8653

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/jvm/clojure/lang/RT.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ static public void addURL(Object url) throws MalformedURLException{
304304
throw new IllegalAccessError("Context classloader is not a DynamicClassLoader");
305305
}
306306

307+
static IPersistentSet loadedPaths = set();
308+
307309
static{
308310
Keyword arglistskw = Keyword.intern(null, "arglists");
309311
Symbol namesym = Symbol.intern("name");
@@ -440,7 +442,10 @@ static public void load(String scriptbase, boolean failIfNotFound) throws IOExce
440442
RT.mapUniqueKeys(CURRENT_NS, CURRENT_NS.deref(),
441443
WARN_ON_REFLECTION, WARN_ON_REFLECTION.deref()
442444
,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);
444449
}
445450
finally {
446451
Var.popThreadBindings();
@@ -451,10 +456,13 @@ static public void load(String scriptbase, boolean failIfNotFound) throws IOExce
451456
compile(scriptfile);
452457
else
453458
loadResourceScript(RT.class, scriptfile);
459+
loaded = true;
454460
}
455461
else if(!loaded && failIfNotFound)
456462
throw new FileNotFoundException(String.format("Could not locate %s or %s on classpath.%s", classfile, cljfile,
457463
scriptbase.contains("_") ? " Please check that namespaces with dashes use underscores in the Clojure file name." : ""));
464+
if(loaded)
465+
loadedPaths = (IPersistentSet) loadedPaths.cons(scriptbase);
458466
}
459467

460468
static void doInit() throws ClassNotFoundException, IOException{
@@ -2187,10 +2195,10 @@ static public Class classForNameNonLoading(String name) {
21872195
return classForName(name, false, baseLoader());
21882196
}
21892197

2190-
static public Class loadClassForName(String name) {
2198+
static public Class classForNameNonLoadingSafe(String name) {
21912199
try
21922200
{
2193-
classForNameNonLoading(name);
2201+
return classForNameNonLoading(name);
21942202
}
21952203
catch(Exception e)
21962204
{
@@ -2199,7 +2207,12 @@ static public Class loadClassForName(String name) {
21992207
else
22002208
throw Util.sneakyThrow(e);
22012209
}
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);
22032216
}
22042217

22052218
static public float aget(float[] xs, int i){

0 commit comments

Comments
 (0)