Skip to content

Commit 39854b7

Browse files
author
Stuart Sierra
committed
CLASSPATH-7 Check loader satisfies URLClasspath
In some environments, the classloader hierarchy may contain classloaders which do not inherit from java.net.URLClassLoader and which cannot be extended to the clojure.java.classpath/URLClasspath protocol. To prevent exceptions in these environments, check that classloaders satisfy the protocol before calling .urls. See http://dev.clojure.org/jira/browse/CLASSPATH-7
1 parent 6c741c9 commit 39854b7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/clojure/clojure/java/classpath.clj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
URLClasspath
3232
(urls [loader] (seq (.getURLs loader))))
3333

34+
(defn get-urls
35+
"Returns a sequence of java.net.URL objects used by this
36+
classloader, or nil if the classloader does not sastify the
37+
URLClasspath protocol."
38+
[loader]
39+
(when (satisfies? URLClasspath loader)
40+
(urls loader)))
41+
3442
(defn jar-file?
3543
"Returns true if file is a normal file with a .jar or .JAR extension."
3644
[f]
@@ -58,7 +66,7 @@
5866
(defn loader-classpath
5967
"Returns a sequence of File paths from a classloader."
6068
[loader]
61-
(map io/as-file (urls loader)))
69+
(map io/as-file (get-urls loader)))
6270

6371
(defn classpath
6472
"Returns a sequence of File objects of the elements on the classpath."

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy