Hi, I want a Java application to support evaluation of older and newer clojure scripts that may not run on the same clojure versions/ releases. I want to support this without restarting the application.
The approach I'm trying is to load clojure from its own classloader. My idea is to GC the classloader whenever a clojure version is not required anymore. Rinse and repeat. At this point, it doesn't work. Clojure is NOT in the classpath. I use a custom URLClassLoader which is given the right clojure path dynamically. However, clojure throws an Exception because it seems to disregard the classloader it is being loaded with. Instead, it uses the system class loader (or a child or the system class loader). Moreover, I can't call RT.addURL because the exception is thrown from static initializer blocks. The exception is shown below. Example code which throws: // urls contain path to clojure URLClassLoader classLoader = new URLClassLoader(urls); // Below: doesn't work Class.forName("clojure.core__init", true, classLoader); Class.forName("clojure.lang.RT", true, classLoader); Class.forName("clojure.lang.Compiler", true, classLoader); // This works but throws whenever _methClojureLoad is called clazz = classLoader.loadClass("clojure.lang.Compiler"); _methClojureLoad = clazz.getMethod("load", Reader.class, String.class, String.class); Am I wasting my time with this approach? Is there even a way to do what I want? Thanks, Max Exception in thread "main" java.lang.ExceptionInInitializerError at clojure.core__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at DocumentMgr.loadClojure(DocumentMgr.java:198) at DocumentMgr.newDocument(DocumentMgr.java:73) at Application.start(Application.java:105) at Application.main(Application.java:41) Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/core__init.class or clojure/core.clj on classpath: at clojure.lang.RT.<clinit>(RT.java:290) ... 7 more Caused by: java.io.FileNotFoundException: Could not locate clojure/ core__init.class or clojure/core.clj on classpath: at clojure.lang.RT.load(RT.java:409) at clojure.lang.RT.load(RT.java:376) at clojure.lang.RT.doInit(RT.java:413) at clojure.lang.RT.<clinit>(RT.java:286) ... 7 more --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---