Request for test: CLASSPATH-8 fix for Java 9

82 views
Skip to first unread message

Stuart Sierra

unread,
Mar 10, 2018, 3:25:57 PM3/10/18
to Clojure Dev
I just implemented a fix for CLASSPATH-8. It is available in a patch on JIRA and on GitHub as the branch fix-CLASSPATH-8.

The change is to support Java 9. Prior to now, org.clojure/java.classpath used the URLClassLoader hierarchy, starting at clojure.lang.RT/baseLoader, to discover the classpath. This was to support environments that create custom classloader contexts, such as Java application servers like Tomcat or Jetty.

In Java 9, the default classloader hierarchy does not contain URLClassLoader, so clojure.java.classpath/classpath returns an empty sequence.

The only solution I can see is the Java System Property java.class.path. This works in a plain Clojure REPL running on Java 9 but may not work in other environments.

I have attempted to preserve backwards compatibility by keeping the existing behavior (URLClassLoader) as the default and only falling back to java.class.path when the URLClassLoader search produces no results.

For anyone running Clojure in "unusual" environments such as application containers or build tools, I would appreciate it if you could test this patch and report here if you encounter any problems.

Local installation instructions:

cd java.classpath
git checkout fix-CLASSPATH-8
mvn install

Then add the dependency to your project:

[org.clojure/java.classpath "0.3.0-SNAPSHOT"]

In your project, run:

(require '[clojure.java.classpath :as cp])
(cp/classpath)

and verify that it returns the correct classpath list.

Thank you!
–S
Reply all
Reply to author
Forward
0 new messages