(app-loader)
Get the application (aka system) classloader
Get the application (aka system) classloader
(base-loader)
Get the loader that Clojure uses internally to load files
This is usually the current context classloader, but can also be clojure.lang.Compiler/LOADER.
Get the loader that Clojure uses internally to load files This is usually the current context classloader, but can also be clojure.lang.Compiler/LOADER.
(cl-id cl)
return a symbol identifying the cl, mainly meant for concise printing
return a symbol identifying the cl, mainly meant for concise printing
(cl-name cl)
Get a classlaoders's defined name
Get a classlaoders's defined name
(classloader-chain)
(classloader-chain cl)
Get the chain of parent classloaders, all the way to the system AppClassLoader and PlatformClassLoader.
Get the chain of parent classloaders, all the way to the system AppClassLoader and PlatformClassLoader.
(classpath)
clojure.java.classpath does not play well with the post-Java 9 application class loader, which is no longer a URLClassLoader, even though ostensibly it tries to cater for this, but in practice if any URLClassLoader or DynamicClassLoader higher in the chain contains a non-empty list of URLs, then this shadows the system classpath.
clojure.java.classpath does not play well with the post-Java 9 application class loader, which is no longer a URLClassLoader, even though ostensibly it tries to cater for this, but in practice if any URLClassLoader or DynamicClassLoader higher in the chain contains a non-empty list of URLs, then this shadows the system classpath.
(classpath-chain)
(classpath-chain cl)
Return a list of classloader names, and the URLs they have on their classpath
Mainly meant for inspecting the current state of things.
Return a list of classloader names, and the URLs they have on their classpath Mainly meant for inspecting the current state of things.
(classpath-directories)
Returns a sequence of File objects for the directories on classpath.
Returns a sequence of File objects for the directories on classpath.
(classpath-jarfiles)
Returns a sequence of JarFile objects for the JAR files on classpath.
Returns a sequence of JarFile objects for the JAR files on classpath.
(compiler-loader)
Get the clojure.lang.Compiler/LOADER, if set
This is the loader Clojure uses to load code with, if the var is set. If not it falls back to the context classloader.
Get the clojure.lang.Compiler/LOADER, if set This is the loader Clojure uses to load code with, if the var is set. If not it falls back to the context classloader.
(context-classloader)
(context-classloader thread)
Get the context classloader for the current thread
Get the context classloader for the current thread
(debug-context-classloader thread cl)
Replace calls to .setContextClassloader
with this to get insights into
who/what/where/when/how is changing the classloader
Replace calls to `.setContextClassloader` with this to get insights into who/what/where/when/how is changing the classloader
(dynamic-classloader parent)
Construct a new DynamicClassLoader
Construct a new DynamicClassLoader
(dynamic-classloader? cl)
Is the given classloader a [[clojure.lang.DynamicClassLoader]]
Is the given classloader a [[clojure.lang.DynamicClassLoader]]
(ensure-trailing-slash path)
URLClassPath looks for a trailing slash to determine whether something is a directory instead of a jar, so add trailing slashes to everything that doesn't look like a JAR.
URLClassPath looks for a trailing slash to determine whether something is a directory instead of a jar, so add trailing slashes to everything that doesn't look like a JAR.
(file->ns-name filename)
Get the ns name for a given clj file name
Get the ns name for a given clj file name
(find-resources regex)
Scan 'the classpath' for resources that match the given regex.
Scan 'the classpath' for resources that match the given regex.
(git-pull-lib lib)
(git-pull-lib deps-file lib)
Update the :git/sha in deps.edn for a given library to the latest sha in a branch
Uses :git/branch
defaulting to main
Update the :git/sha in deps.edn for a given library to the latest sha in a branch Uses `:git/branch` defaulting to `main`
(install-priority-loader!)
(install-priority-loader! paths)
Install the new priority loader as immediate parent of the bottom-most DynamicClassloader, discarding any further descendants. After this the chain is
[priority-classloader DynamicClassLoader AppClassLoader PlatformClassLoader]
Do this for every thread that has a DynamicClassLoader as the context classloader, or any of its parents.
We need to do this from a separate thread, hence the future
call, because
nREPL's interruptible-eval resets the context-classloader at the end of the
evaluation, so this needs to happen after that has happened.
Start the JVM with -Dlambdaisland.classpath.debug=true
to get debugging
output.
Install the new priority loader as immediate parent of the bottom-most DynamicClassloader, discarding any further descendants. After this the chain is [priority-classloader DynamicClassLoader AppClassLoader PlatformClassLoader] Do this for every thread that has a DynamicClassLoader as the context classloader, or any of its parents. We need to do this from a separate thread, hence the `future` call, because nREPL's interruptible-eval resets the context-classloader at the end of the evaluation, so this needs to happen after that has happened. Start the JVM with `-Dlambdaisland.classpath.debug=true` to get debugging output.
(platform-loader)
Get the platform classloader
Get the platform classloader
(priority-classloader cl urls)
A modified URLClassloader
It will give precedence to its own URLs over its parents, then to whatever resources its immediate parent returns, and only then passing the request up the chain, which will then proceed with the bottom most classloaders (Boot, then Platform, then App).
We install this as the child of the bottom most clojure.lang.DynamicClassloader that we find.
The logic here relies on the fact that DynamicClassLoader or its parent
URLClassLoader do not implement the getResource
/getResources
methods, they
rely on the parent implementation in ClassLoader, which gives precedence to
ancestors, before proceeding to call findResource
/findResources
, which
URLClassLoader/DynamicClassloader do implement. This classloader reverses that
logic, so that the system classloader doesn't shadow our own classpath
entries.
A modified URLClassloader It will give precedence to its own URLs over its parents, then to whatever resources its immediate parent returns, and only then passing the request up the chain, which will then proceed with the bottom most classloaders (Boot, then Platform, then App). We install this as the child of the bottom most clojure.lang.DynamicClassloader that we find. The logic here relies on the fact that DynamicClassLoader or its parent URLClassLoader do not implement the `getResource`/`getResources` methods, they rely on the parent implementation in ClassLoader, which gives precedence to ancestors, before proceeding to call `findResource`/`findResources`, which URLClassLoader/DynamicClassloader do implement. This classloader reverses that logic, so that the system classloader doesn't shadow our own classpath entries.
(priority-classloader? cl)
Is the given classloader a priority-classloader
Is the given classloader a [[priority-classloader]]
(read-basis)
Read the basis (extended deps.edn) that Clojure started with, using the
clojure.basis
system property.
Read the basis (extended deps.edn) that Clojure started with, using the `clojure.basis` system property.
(resources name)
(resources cl name)
The plural of [[clojure.java.io/resource]], find all resources with the given name on the classpath.
Useful for checking shadowing issues, in case a library ended up on the classpath multiple times.
The plural of [[clojure.java.io/resource]], find all resources with the given name on the classpath. Useful for checking shadowing issues, in case a library ended up on the classpath multiple times.
(root-loader)
(root-loader cl)
Find the bottom-most DynamicClassLoader in the chain of parent classloaders
Find the bottom-most DynamicClassLoader in the chain of parent classloaders
(update-classpath! basis-opts)
Use the given options to construct a basis (see [[deps/create-basis]]), then add any classpath-roots that aren't part of the system classpath yet to the classpath, by installing an extra classloader over Clojure's DynamicClassloader which takes precedence.
This is the closest we can get to "replacing" the classpath. We can't remove any entries from the system classpath (the classpath the JVM booted with), but we can make sure any extra entries get precedence.
Use the given options to construct a basis (see [[deps/create-basis]]), then add any classpath-roots that aren't part of the system classpath yet to the classpath, by installing an extra classloader over Clojure's DynamicClassloader which takes precedence. This is the closest we can get to "replacing" the classpath. We can't remove any entries from the system classpath (the classpath the JVM booted with), but we can make sure any extra entries get precedence.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close