hawkeye
hawkeye

Reputation: 35702

class clash with lein classloader - .class over .clj?

If I have two jars on my leiningen classpath:

a.jar 
b.jar

And a.jar contains

c\d_init.class

and b.jar contains

c\d.clj

Then I try to load the c.d namespace on my project:

(ns e.core
  (:require [c.d :as resolutiontest]))

Is it guaranteed by the Clojure classloader that c\d_init.class will always get loaded over c\d.clj?

Upvotes: 1

Views: 64

Answers (1)

juan.facorro
juan.facorro

Reputation: 9930

Based on the code here (Clojure 1.5.1), it would seem that d__init.class file will get loaded over d.clj, as long as the modification date for d.clj is less that the one for the .class file.

 ...
 if((classURL != null &&
    (cljURL == null || lastModified(classURL, classfile) > lastModified(cljURL, cljfile)))
   || classURL == null) {
    try {
 ...

Upvotes: 2

Related Questions