prepl does not run with a DynamicClassLoader

Description

clojure.main sets the thread context classloader to be a DynamicClassLoader, providing an environment to tap into the Clojure classloader environment. prepl should do the same. This would support things like add-lib when using prepl (for tools like REBL that use prepl).

Repro with rebl and add-lib...

deps.edn:

Actual:

Desired:

Same problem also exists with clojure.core.server/repl, provided for use in a socket server.

Approach: Create a macro `with-dynamic-loader` that ensures (and doesn't replace if it exists) the thread context classloader, evaluates the binding, then reverts the loader. This macro is generic and could potentially be moved elsewhere.

Patch: clj-2540-2.patch

Environment

None

Activity

Show:
Alex Miller
March 5, 2020, 2:49 PM

Currently clojure.main/repl bakes in the creation of a DynamicClassLoader. The patch starts to stretch towards a reusable piece of functionality (with-dynamic-loader) and adds that into prepl and socket server.

Stu's comments from looking at this is that instead of baking this into repls we should really be pulling these things apart more. So in clojure.main/repl, maybe that should not be creating a DCL, but the caller of repl should be creating a DCL when needed. Needs some more thought on composition.

Assignee

Unassigned

Reporter

Alex Miller

Approval

Vetted

Patch

Code

Fix versions

Affects versions

Priority

Major
Configure