On Oct 28, 8:48 am, Stuart Halloway <[EMAIL PROTECTED]> wrote: > Hi all, > > When I am troubleshooting classloader problems I find myself wanting > to know the list of URLs currently on the classpath. I didn't find > this exposed anywhere, so I wrote the functions below. > > Usage: > > (take 3 (classpath-url-seq)) > -> ("file:/Users/stuart/relevance/personal/SHCLOJ_svn/Book/code/" > "file:/Users/stuart/repos/clojure-contrib/clojure-contrib.jar" > "file:/Users/stuart/devtools/java/joda-time-1.5.2/joda- > time-1.5.2.jar") > > Of course to be most helpful this needs to be in clojure.jar -- > otherwise you might have classloader problems loading the classloader > help code. :-) Not sure if this is general enough to deserve to be in > clojure.jar, but you're welcome to it if others find it useful. > > Stuart > > ; ------------------------------------------------------- > (defn classloader-seq > ([] (classloader-seq (clojure.lang.RT/baseLoader))) > ([cl] > (loop [loaders (vector cl)] > (if (nil? (last loaders)) > (drop-last loaders) > (recur (conj loaders (.getParent (last loaders)))))))) > > (defn classpath-url-seq [& args] > (map (memfn toExternalForm) > (reduce concat > (map (memfn getURLs) > (apply classloader-seq args)))))
I like it. I think it is a good idea to put it in clojure.jar. It certainly helps troubleshooting. Allen --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---