Liking cljdoc? Tell your friends :D

lambdaisland.classpath


app-loaderclj

(app-loader)

Get the application (aka system) classloader

Get the application (aka system) classloader
sourceraw docstring

base-loaderclj

(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.
sourceraw docstring

cl-idclj

(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
sourceraw docstring

cl-nameclj

(cl-name cl)

Get a classloaders's defined name

Get a classloaders's defined name
sourceraw docstring

classloader-chainclj

(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.
sourceraw docstring

classpathclj

(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.
sourceraw docstring

classpath-chainclj

(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.
sourceraw docstring

classpath-directoriesclj

(classpath-directories)

Returns a sequence of File objects for the directories on classpath.

Returns a sequence of File objects for the directories on classpath.
sourceraw docstring

classpath-jarfilesclj

(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.
sourceraw docstring

compiler-loaderclj

(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.
sourceraw docstring

context-classloaderclj

(context-classloader)
(context-classloader thread)

Get the context classloader for the current thread

Get the context classloader for the current thread
sourceraw docstring

debug!clj

(debug!)
(debug! enable?)
source

debug-context-classloadercljmacro

(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
sourceraw docstring

debug-context-classloader*clj

(debug-context-classloader* ns meta-form thread cl)
source

debug?clj

(debug?)
source

dynamic-classloaderclj

(dynamic-classloader parent)

Construct a new DynamicClassLoader

Construct a new DynamicClassLoader
sourceraw docstring

dynamic-classloader?clj

(dynamic-classloader? cl)

Is the given classloader a [[clojure.lang.DynamicClassLoader]]

Is the given classloader a [[clojure.lang.DynamicClassLoader]]
sourceraw docstring

ensure-trailing-slashclj

(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.
sourceraw docstring

fg-blueclj

source

fg-greenclj

source

fg-redclj

source

fg-resetclj

source

fg-yellowclj

source

file->ns-nameclj

(file->ns-name filename)

Get the ns name for a given clj file name

Get the ns name for a given clj file name
sourceraw docstring

find-resourcesclj

(find-resources regex)

Scan 'the classpath' for resources that match the given regex.

Scan 'the classpath' for resources that match the given regex.
sourceraw docstring

git-pull-libclj

(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`
sourceraw docstring

git-pull-lib*clj

(git-pull-lib* loc lib)
source

install-priority-loader!clj

(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.
sourceraw docstring

parentclj

(parent cl)

Get the parent classloader

Get the parent classloader
sourceraw docstring

platform-loaderclj

(platform-loader)

Get the platform classloader

Get the platform classloader
sourceraw docstring

priority-classloaderclj

(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.
sourceraw docstring

priority-classloader?clj

(priority-classloader? cl)

Is the given classloader a priority-classloader

Is the given classloader a [[priority-classloader]]
sourceraw docstring

read-basisclj

(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.
sourceraw docstring

resourcesclj

(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.
sourceraw docstring

root-loaderclj

(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
sourceraw docstring

update-classpath!clj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close