This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-07
Channels
- # architecture (35)
- # babashka (9)
- # beginners (31)
- # biff (15)
- # calva (8)
- # cider (7)
- # clerk (4)
- # clj-kondo (24)
- # clj-yaml (10)
- # clojure (58)
- # clojure-europe (65)
- # clojure-japan (1)
- # clojure-nl (1)
- # clojure-norway (89)
- # clojure-spec (1)
- # clojure-sweden (1)
- # clojure-uk (8)
- # clojurescript (14)
- # cursive (3)
- # datahike (1)
- # datomic (29)
- # emacs (8)
- # graalvm (20)
- # graphql (1)
- # gratitude (2)
- # helix (6)
- # hyperfiddle (65)
- # jobs-discuss (7)
- # leiningen (1)
- # life (3)
- # lsp (6)
- # malli (14)
- # missionary (12)
- # nrepl (8)
- # off-topic (24)
- # polylith (29)
- # reagent (14)
- # sci (14)
- # shadow-cljs (6)
- # spacemacs (10)
- # sql (4)
I have a function that works in Clojure, but doesn't in Babashka because the classloader is different. I'm wondering what would be an idiomatic way of solving this:
(defn- resources [path]
(let [cl (.. Thread currentThread getContextClassLoader)]
(enumeration-seq (.getResources cl path))))
Thanks! I noticed there was a class-loader in babashka.impl.classpath, but that sounds like an internal namespace.
This works in bb currently:
bb -e '(map str (.getURLs (clojure.lang.RT/baseLoader)))'
also this works, if you are willing to write bb-specific code:
(babashka.classpath/split-classpath (babashka.classpath/get-classpath))
Perfect, thanks!
When running code in bb, the following is done:
(binding [clojure.lang.Compiler/LOADER @cp/the-url-loader] ...)
to make the above interop possible. not sure if any other bindings make sense.Perhaps running setContextClassLoader()
with the "internal" classloader would make your original interop possible
Using baseLoader works. I did vaguely recall that there was some reason I used the thread context class loader, but I can't remember exactly why.