java

João Galrito 2022-01-12T18:38:46.002300Z

Hello! When requiring clojure namespace A from Java (and I assume it works the same in the REPL) that itself requires a clojure namespace B, what happens to A when namespace B is modified and reloaded?

João Galrito 2022-01-12T18:39:53.003Z

and also, what if I load namespace C that also depends on namespace B, but namespace B has changed since when namespace A was loaded

Alex Miller (Clojure team) 2022-01-12T18:47:54.003200Z

on your first question - nothing

Alex Miller (Clojure team) 2022-01-12T18:48:28.003900Z

on the second question, C will use the updated version of B

Alex Miller (Clojure team) 2022-01-12T18:49:39.004900Z

I was kind of assuming you had done the first thing before the second, but a namespace will not be reloaded unless you explicitly request it to be - either by a direct load or by using the require :reload / or :reload-all for all transitive namespaces

Alex Miller (Clojure team) 2022-01-12T18:51:03.006200Z

as a general thing, loaded code refers to other code via their var, and if the other code is reloaded, the var will be dereferenced to the new impl. that's generally how reloading works in Clojure at the repl etc

Alex Miller (Clojure team) 2022-01-12T18:51:51.007100Z

(caveat, there are things the can make this not true - capturing the deref'ed value of a var, compiling with direct linking etc)

João Galrito 2022-01-12T18:58:15.007900Z

so unless I required B from A with :reload, even if C is loaded with the new version of B, A will continue to use the old version of B?

Alex Miller (Clojure team) 2022-01-12T20:17:15.008200Z

yes, reload only happens if requested

João Galrito 2022-01-12T20:18:59.008500Z

alright, thank you @alexmiller 🙂

emccue 2022-01-12T20:31:23.008900Z

does anyone have a clear understanding of why module-path and class-path are different values?

emccue 2022-01-12T20:31:53.009500Z

like - if i were to just duplicate what is on the classpath to the module path what would the downside be

emccue 2022-01-12T20:32:19.010200Z

java --class-path=... --module-path=...

Alex Miller (Clojure team) 2022-01-12T21:15:28.011Z

they are different approaches to declaring what classes are available to the JVM

Alex Miller (Clojure team) 2022-01-12T21:16:02.011700Z

classpath (the "old" approach) is file-oriented and everything "merges" into one file tree conceptually

Alex Miller (Clojure team) 2022-01-12T21:16:41.012400Z

the module-path chunks classes into modules and modules declare dependencies on other modules (and define additional visibility boundaries)

Alex Miller (Clojure team) 2022-01-12T21:17:57.013800Z

I think the vision of modules (Java 9+) is that you specify everything as modules (so no classpath) but the reality is that not everything is a module. there are some rules to treat jars as automatic modules, but the middle place is kind of a messy world