File tree Expand file tree Collapse file tree 3 files changed +27
-10
lines changed
src/cider/nrepl/middleware
test/clj/cider/nrepl/middleware Expand file tree Collapse file tree 3 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 2323 (str " file:" path)
2424 (str " file:" path dir-separator))]
2525 (new java.net.URL url)))
26- paths)]
27- (new java.net.URLClassLoader (into-array java.net.URL urls))))
26+ paths)
27+ jdk-sources (->> [#_" see '## Classpath' notes at `cider.nrepl.middleware.util.java`"
28+ [" src.zip" ]
29+ [" lib" " tools.jar" ]]
30+ (map (partial apply java/jdk-resource-url))
31+ (remove nil?))]
32+ (new java.net.URLClassLoader (into-array java.net.URL (concat urls jdk-sources)))))
2833
2934(defn- resource-full-path [relative-path]
3035 (if (u/boot-project? )
Original file line number Diff line number Diff line change 4444 (-> (io/file (System/getProperty " java.home" ))
4545 (.getParentFile )))
4646
47+ (defn jdk-resource-url
48+ " Returns url to file at PATH-SEGMENTS relative to `jdk-root`."
49+ [& path-segments]
50+ (let [f (apply io/file jdk-root path-segments)]
51+ (when (.canRead f)
52+ (io/as-url f))))
53+
4754(def jdk-sources
4855 " The JDK sources path. If available, this is added to the classpath. By
4956 convention, this is the file `src.zip` in the root of the JDK directory."
50- (let [zip (io/file jdk-root " src.zip" )]
51- (when (.canRead zip)
52- (add-classpath! (io/as-url zip)))))
57+ (some-> (jdk-resource-url " src.zip" ) add-classpath!))
5358
5459(def jdk-tools
5560 " The JDK `tools.jar` path. If available, this is added to the classpath."
56- (let [jar (io/file jdk-root " lib" " tools.jar" )]
57- (when (.canRead jar)
58- (add-classpath! (io/as-url jar)))))
61+ (some-> (jdk-resource-url " lib" " tools.jar" ) add-classpath!))
5962
6063; ;; ## Javadoc URLs
6164; ; Relative Javadoc URLs can be constructed from class/member signatures.
Original file line number Diff line number Diff line change 66 [clojure.set :as set]
77 [clojure.string :as str]
88 [cider.nrepl.middleware.info :as info]
9+ [cider.nrepl.middleware.util.java :as java]
910 [cider.nrepl.middleware.util.meta :as m]
1011 [cider.nrepl.middleware.util.misc :as util]
1112 [cider.nrepl.test-session :as session]
7071 (let [tmp-jar-path " jar:file:fake/clojure.jar" ]
7172 (try
7273 (System/setProperty " fake.class.path" tmp-jar-path)
73- (is (= (-> (#'cider.nrepl.middleware.info/boot-class-loader ) .getURLs last str)
74- " file:fake/clojure.jar" ))
74+ (is (some #{" file:fake/clojure.jar" }
75+ (->> (#'cider.nrepl.middleware.info/boot-class-loader ) .getURLs (map str))))
76+ (finally
77+ (System/clearProperty " fake.class.path" )))))
78+ (testing " include sources when avaliable"
79+ (when-let [src-url (java/jdk-resource-url " src.zip" )]
80+ (try
81+ (System/setProperty " fake.class.path" tmp-dir-name)
82+ (is (some #{src-url}
83+ (.getURLs (#'cider.nrepl.middleware.info/boot-class-loader ))))
7584 (finally
7685 (System/clearProperty " fake.class.path" )))))))
7786
You can’t perform that action at this time.
0 commit comments