(add-url path)
(add-url loader path)
adds a classpath to the loader
(add-url (fs/path "path/to/somewhere"))
adds a classpath to the loader (add-url (fs/path "path/to/somewhere"))
(all-jars)
(all-jars loader)
gets all jars on the classloader
(all-jars) => seq?
gets all jars on the classloader (all-jars) => seq?
(all-paths)
(all-paths loader)
gets all paths on the classloader
(all-paths) => seq?
gets all paths on the classloader (all-paths) => seq?
(all-urls)
(all-urls loader)
returns all urls contained by the loader
(all-urls)
returns all urls contained by the loader (all-urls)
(any-load-class cls _ _)
loads a class, storing class into the global cache
(any-load-class test.Cat nil nil) => test.Cat
loads a class, storing class into the global cache (any-load-class test.Cat nil nil) => test.Cat
(classpath)
(classpath loader)
returns the classpath for the loader, including parent loaders
(classpath)
returns the classpath for the loader, including parent loaders (classpath)
(delegation cl)
returns a list of classloaders in order of top to bottom
(-> (Thread/currentThread) (.getContextClassLoader) (delegation)) => list?
returns a list of classloaders in order of top to bottom (-> (Thread/currentThread) (.getContextClassLoader) (delegation)) => list?
(dynamic-classloader)
(dynamic-classloader urls)
(dynamic-classloader urls parent)
creates a dynamic classloader instance
(dynamic-classloader []) => clojure.lang.DynamicClassLoader
creates a dynamic classloader instance (dynamic-classloader []) => clojure.lang.DynamicClassLoader
(dynamic-load-bytes bytes loader {:keys [name source] :as opts})
loads a class from bytes
(dynamic-load-bytes (to-bytes "target/classes/test/Cat.class") (dynamic-classloader) {:name "test.Cat"}) => test.Cat
loads a class from bytes (dynamic-load-bytes (to-bytes "target/classes/test/Cat.class") (dynamic-classloader) {:name "test.Cat"}) => test.Cat
(dynamic-load-coords coordinates loader {:keys [entry-path] :as opts})
loads a class from a coordinate
(.getName (dynamic-load-coords '[org.yaml/snakeyaml "1.5"] (dynamic-classloader) {:name "org.yaml.snakeyaml.Dumper" :entry-path "org/yaml/snakeyaml/Dumper.class"})) => "org.yaml.snakeyaml.Dumper"
loads a class from a coordinate (.getName (dynamic-load-coords '[org.yaml/snakeyaml "1.5"] (dynamic-classloader) {:name "org.yaml.snakeyaml.Dumper" :entry-path "org/yaml/snakeyaml/Dumper.class"})) => "org.yaml.snakeyaml.Dumper"
(dynamic-load-string path loader {:keys [entry-path] :as opts})
loads a class from a path string
(dynamic-load-string "<.m2>/org/yaml/snakeyaml/1.5/snakeyaml-1.5.jar" (dynamic-classloader) {:name "org.yaml.snakeyaml.Dumper" :entry-path "org/yaml/snakeyaml/Dumper.class"}) => org.yaml.snakeyaml.Dumper
loads a class from a path string (dynamic-load-string "<.m2>/org/yaml/snakeyaml/1.5/snakeyaml-1.5.jar" (dynamic-classloader) {:name "org.yaml.snakeyaml.Dumper" :entry-path "org/yaml/snakeyaml/Dumper.class"}) => org.yaml.snakeyaml.Dumper
(get-url path)
(get-url loader path)
returns the required url
(get-url (fs/path "src")) ;;#object[java.net.URL 0x3d202d52 "file:/Users/chris/Development/hara/hara/src/"] => java.net.URL
returns the required url (get-url (fs/path "src")) ;;#object[java.net.URL 0x3d202d52 "file:/Users/chris/Development/hara/hara/src/"] => java.net.URL
(has-url? path)
(has-url? loader path)
checks whether the classloader has the following url
(has-url? (fs/path "src")) => true
checks whether the classloader has the following url (has-url? (fs/path "src")) => true
(load-class x)
(load-class x opts)
(load-class x opts loader)
loads class from an external source
(.getName (load-class "target/classes/test/Cat.class" {:name "test.Cat"})) => "test.Cat"
loads class from an external source (.getName (load-class "target/classes/test/Cat.class" {:name "test.Cat"})) => "test.Cat"
(remove-url path)
(remove-url loader path)
removes url from classloader
(do (add-url (fs/path "path/to/somewhere")) (has-url? (fs/path "path/to/somewhere"))) => true
(remove-url (fs/path "path/to/somewhere")) (has-url? (fs/path "path/to/somewhere")) => false
removes url from classloader (do (add-url (fs/path "path/to/somewhere")) (has-url? (fs/path "path/to/somewhere"))) => true (remove-url (fs/path "path/to/somewhere")) (has-url? (fs/path "path/to/somewhere")) => false
opens .class
file from an external source
(to-bytes "target/classes/test/Dog.class")
=> check/bytes?
opens `.class` file from an external source (to-bytes "target/classes/test/Dog.class") => check/bytes?
(unload-class name)
unloads a class from the current namespace
(unload-class "test.Cat") ;; #object[java.lang.ref.SoftReference 0x10074132 ;; "java.lang.ref.SoftReference@10074132"]
unloads a class from the current namespace (unload-class "test.Cat") ;; #object[java.lang.ref.SoftReference 0x10074132 ;; "java.lang.ref.SoftReference@10074132"]
(url-classloader urls)
(url-classloader urls parent)
returns a java.net.URLClassLoader
from a list of strings
(->> (url-classloader ["/dev/null/"]) (.getURLs) (map str)) => ["file:/dev/null/"]
returns a `java.net.URLClassLoader` from a list of strings (->> (url-classloader ["/dev/null/"]) (.getURLs) (map str)) => ["file:/dev/null/"]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close