Clojure 如何在类路径中查找源代码?

How does Clojure find sources in the classpath?

Clojure 中的库与 Java 一样打包在 jar 中。
但是这些 jar 包含要编译的源代码,因此,理论上,Clojure 需要检查类路径中每个 jar 中的每个文件,以查看它是否是 Clojure 源文件(听起来效率低下),特别是如果代码需要进行 AOT 编译。

Clojure 是否真的这样做了,或者它是否有一些启发式方法来找出哪些 jar 包含 .clj 文件?

要访问 Clojure 代码,首先您必须要求命名空间。调用 require 时,它​​将从命名空间名称派生源文件名。

来自 require 的 Clojure 文档:

A lib's name also locates its root directory within classpath using Java's package name to classpath-relative path mapping.

[...]

The root resource path is derived from the lib name in the following manner: Consider a lib named by the symbol 'x.y.z; it has the root directory /x/y/, and its root resource is /x/y/z.clj, or /x/y/z.cljc if /x/y/z.clj does not exist.