Browse files

CLASSPATH-5: extensible protocol to other classloaders

Original patch by Jim Crossley
  • Loading branch information...
stuartsierra committed Jan 7, 2014
1 parent c468d14 commit 0b3401cc97fcd68b7d095312e49ed0952c1a1a04
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/main/clojure/clojure/java/classpath.clj
@@ -22,6 +22,15 @@
(java.util.jar JarFile JarEntry)
( URL URLClassLoader)))
+(defprotocol URLClasspath
+ (urls [loader]
+ "Returns a sequence of objects representing locations
+ which this classloader will search for classes and resources."))
+ URLClasspath
+ (urls [loader] (seq (.getURLs loader))))
(defn jar-file?
"Returns true if file is a normal file with a .jar or .JAR extension."
@@ -49,8 +58,7 @@
(defn loader-classpath
"Returns a sequence of File paths from a classloader."
- (when (instance? loader)
- (map io/as-file (.getURLs ^ loader))))
+ (map io/as-file (urls loader)))
(defn classpath
"Returns a sequence of File objects of the elements on the classpath."

0 comments on commit 0b3401c

Please sign in to comment.