Skip to content

Commit e5a104e

Browse files
bronsastuarthalloway
authored andcommitted
CLJ-1544 force reloading of namespaces during AOT compilation
Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent 4afd4a7 commit e5a104e

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/clj/clojure/core.clj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5670,6 +5670,19 @@
56705670
(load-one lib need-ns require)
56715671
@*loaded-libs*))))
56725672

5673+
(defn- already-compiled? [lib]
5674+
(let [path (subs (root-resource lib) 1)
5675+
clj-path (str path ".clj")
5676+
class-path (str path "__init.class")
5677+
loader (clojure.lang.RT/baseLoader)
5678+
compiled-file (java.io.File. (str *compile-path* "/" class-path))
5679+
clj-url (.getResource loader clj-path)]
5680+
(or (and (.exists compiled-file)
5681+
(or (nil? clj-url)
5682+
(> (clojure.lang.RT/lastModified (-> compiled-file .toURI .toURL) class-path)
5683+
(clojure.lang.RT/lastModified clj-url clj-path))))
5684+
(.getResource loader class-path))))
5685+
56735686
(defn- load-lib
56745687
"Loads a lib with options"
56755688
[prefix lib & options]
@@ -5679,7 +5692,9 @@
56795692
(let [lib (if prefix (symbol (str prefix \. lib)) lib)
56805693
opts (apply hash-map options)
56815694
{:keys [as reload reload-all require use verbose]} opts
5682-
loaded (contains? @*loaded-libs* lib)
5695+
loaded (and (contains? @*loaded-libs* lib)
5696+
(or (not *compile-files*)
5697+
(already-compiled? lib)))
56835698
load (cond reload-all
56845699
load-all
56855700
(or reload (not require) (not loaded))

0 commit comments

Comments
 (0)