From e3de281fa731ee81c3a012200c0c94b4e2cecded Mon Sep 17 00:00:00 2001 From: Jeff Valk Date: Sun, 24 Jan 2021 12:48:27 -0500 Subject: [PATCH] Make dynamic classpath modification robust to compiler loader binding When the current classloader has no modifiable ancestor, do not rely on the compiler's classloader var binding, as it may be unbound in some circumstances. Instead, create a new dynamic classloader with the clojure runtime's ancestry. --- src/orchard/java/classpath.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/orchard/java/classpath.clj b/src/orchard/java/classpath.clj index 6935a551..a92b216f 100644 --- a/src/orchard/java/classpath.clj +++ b/src/orchard/java/classpath.clj @@ -72,7 +72,8 @@ [^URL url] (let [loader (or (modifiable-classloader) (set-classloader! - (modifiable-classloader @Compiler/LOADER)))] + (modifiable-classloader (clojure.lang.DynamicClassLoader. + (clojure.lang.RT/baseLoader)))))] (when (dp/add-classpath-url loader url) url)))