Codebase list java-classpath-clojure / c10fc96
CLASSPATH-8: fallback to java.class.path on Java 9 Starting with Java 9, the default class loader is no longer an instance of URLClassLoader, so `classpath` returned an empty sequence. The strategy of using URLClassLoader started with release [0.2.0] to accommodate Java application containers (see [CLASSPATH-1] and [CLASSPATH-2]). After this change, application containers based on URLClassLoader should still work as expected. On Java 9 without an application container, it appears that the `java.class.path` system property is the only way to get the classpath. While this is essentially a bugfix for Java 9 compatibility, it is a change in behavior, hence the version change from 0.2 to 0.3. Stuart Sierra 6 years ago
1 changed file(s) with 9 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6868 (map io/as-file (get-urls loader)))
6969
7070 (defn classpath
71 "Returns a sequence of File objects of the elements on the classpath."
71 "Returns a sequence of File objects of the elements on the
72 classpath. Defaults to searching for instances of
73 java.net.URLClassLoader in the classloader hierarchy above
74 clojure.lang.RT/baseLoader or the given classloader. If no
75 URLClassloader can be found, as on Java 9, falls back to the
76 'java.class'path' system property."
7277 ([classloader]
7378 (distinct
7479 (mapcat
7681 (take-while
7782 identity
7883 (iterate #(.getParent ^ClassLoader %) classloader)))))
79 ([] (classpath (clojure.lang.RT/baseLoader))))
84 ([]
85 (or (seq (classpath (clojure.lang.RT/baseLoader)))
86 (system-classpath))))
8087
8188 (defn classpath-directories
8289 "Returns a sequence of File objects for the directories on classpath."