1
votes

As some parts of Clojure are written in Java is there a way to look into these parts of source code from repl? I'm looking for something like this :

(source clojure.lang.Numbers/add)

As this part is implemented with Java source prints Source not found and returns nil.

1
If you use an IDE like IntelliJ, you can easily ctrl+b you way to the Java sources. That's probably easier to use and more helpful that running a command in the REPL anyway. - Carcigenicate
javadoc does not give you exactly what you're looking for, but it may help set you down the right path. - rriehle

1 Answers

0
votes

It depends on the environment you're using. With plain REPL, you are quite limited.

Two most popular IDEs are Cursive and Emacs Cider.

As @Carcigenicate already pointed out, Cursive has an excellent Java support and allows you to jump to clojure java sources (or any other 3rd party lib sources - providing the sources have been published) easily. It also allows you to debug Clojure compiler itself quite easily.

Emacs Cider has some support for Java. Out of the box you can jump to JDK sources (with some caveats, see https://github.com/clojure-emacs/cider/issues/2687). For other artifacts (like clojure.lang itself or other 3rd party java libs) you should be able to jump to the source code as long as you add the corresponding source jar to :resource-paths (assuming leiningen-based project here). See here for more info about Cider's support.