diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..375901d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +epl.html linguist-documentation diff --git a/.gitignore b/.gitignore index eb5a316..5818281 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target +.cpcache/ diff --git a/CHANGES.md b/CHANGES.md index 437a93c..8959ea7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,26 @@ # java.classpath Change Log + +## 0.3.x series + +### Release [0.3.0] on 2018-May-06 + +* Fix [CLASSPATH-8]: empty classpath returned 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. ## 0.2.x series - -Latest development version is 0.2.4-SNAPSHOT, current Git `master` branch ### Release [0.2.3] on 2015-Nov-06 @@ -42,6 +59,7 @@ +[CLASSPATH-8]: http://dev.clojure.org/jira/browse/CLASSPATH-8 [CLASSPATH-7]: http://dev.clojure.org/jira/browse/CLASSPATH-7 [CLASSPATH-6]: http://dev.clojure.org/jira/browse/CLASSPATH-6 [CLASSPATH-5]: http://dev.clojure.org/jira/browse/CLASSPATH-5 @@ -50,6 +68,7 @@ [CLASSPATH-2]: http://dev.clojure.org/jira/browse/CLASSPATH-2 [CLASSPATH-1]: http://dev.clojure.org/jira/browse/CLASSPATH-1 +[0.3.0]: https://github.com/clojure/java.classpath/tree/java.classpath-0.3.0 [0.2.3]: https://github.com/clojure/java.classpath/tree/java.classpath-0.2.3 [0.2.2]: https://github.com/clojure/java.classpath/tree/java.classpath-0.2.2 [0.2.1]: https://github.com/clojure/java.classpath/tree/java.classpath-0.2.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 021a2ea..658ea8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,12 +3,10 @@ Under the Clojure contrib [guidelines], this project cannot accept pull requests. All patches must be submitted via [JIRA]. -See [Contributing] and the [FAQ] on the Clojure development [wiki] for +See [Contributing] on the Clojure website for more information on how to contribute. -[Clojure contrib]: http://dev.clojure.org/display/doc/Clojure+Contrib -[Contributing]: http://dev.clojure.org/display/community/Contributing -[FAQ]: http://dev.clojure.org/display/community/Contributing+FAQ +[Clojure contrib]: https://clojure.org/community/contrib_libs +[Contributing]: https://clojure.org/community/contributing [JIRA]: http://dev.clojure.org/jira/browse/CLASSPATH -[guidelines]: http://dev.clojure.org/display/community/Guidelines+for+Clojure+Contrib+committers -[wiki]: http://dev.clojure.org/ +[guidelines]: https://clojure.org/community/contrib_howto diff --git a/README.md b/README.md index 3a303f7..0951b90 100644 --- a/README.md +++ b/README.md @@ -5,23 +5,23 @@ ## Releases and Dependency Information -Latest stable release is 0.2.3 +Latest stable release is 0.3.0 [Leiningen] dependency information: - [org.clojure/java.classpath "0.2.3"] + [org.clojure/java.classpath "0.3.0"] [Maven] dependency information: org.clojure java.classpath - 0.2.3 + 0.3.0 [Gradle] dependency information: - compile "org.clojure:java.classpath:0.2.3" + compile "org.clojure:java.classpath:0.3.0" [Leiningen]: http://leiningen.org/ [Maven]: http://maven.apache.org/ @@ -69,6 +69,11 @@ protocol `URLClasspath` to support it. Refer to the source for details. +**Starting with version 0.3.0**, the `classpath` function will fall +back to the `java.class.path` system property if the parent +ClassLoader is not an instance of [URLClassLoader](https://docs.oracle.com/javase/9/docs/api/java/net/URLClassLoader.html), +which is true for Java 9 and later. + ## Developer Information diff --git a/deps.edn b/deps.edn new file mode 100644 index 0000000..3ffcee7 --- /dev/null +++ b/deps.edn @@ -0,0 +1 @@ +{:paths ["src/main/clojure"]} diff --git a/pom.xml b/pom.xml index 32ac3df..dabab64 100644 --- a/pom.xml +++ b/pom.xml @@ -1,13 +1,13 @@ 4.0.0 java.classpath - 0.2.3 - ${project.artifactId} + 1.0.0 + java.classpath org.clojure pom.contrib - 0.1.2 + 0.2.2 @@ -20,6 +20,6 @@ scm:git:git@github.com:clojure/java.classpath.git scm:git:git@github.com:clojure/java.classpath.git git@github.com:clojure/java.classpath.git - java.classpath-0.2.3 + java.classpath-1.0.0 diff --git a/src/main/clojure/clojure/java/classpath.clj b/src/main/clojure/clojure/java/classpath.clj index adcf2de..67a9bd5 100644 --- a/src/main/clojure/clojure/java/classpath.clj +++ b/src/main/clojure/clojure/java/classpath.clj @@ -69,7 +69,12 @@ (map io/as-file (get-urls loader))) (defn classpath - "Returns a sequence of File objects of the elements on the classpath." + "Returns a sequence of File objects of the elements on the + classpath. Defaults to searching for instances of + java.net.URLClassLoader in the classloader hierarchy above + clojure.lang.RT/baseLoader or the given classloader. If no + URLClassloader can be found, as on Java 9, falls back to the + 'java.class'path' system property." ([classloader] (distinct (mapcat @@ -77,7 +82,9 @@ (take-while identity (iterate #(.getParent ^ClassLoader %) classloader))))) - ([] (classpath (clojure.lang.RT/baseLoader)))) + ([] + (or (seq (classpath (clojure.lang.RT/baseLoader))) + (system-classpath)))) (defn classpath-directories "Returns a sequence of File objects for the directories on classpath."