Welcome! Please see the About page for a little more info on how this works.

+2 votes
ago in Java Interop by

In order to provide a hot key in VS Code to show the JavaDocs associated with a selected form (class name or the type of an expression), I wrote the following Joyride script:

https://github.com/seancorfield/vscode-calva-setup/blob/develop/joyride/scripts/javadoc.cljs#L15

This highlights three issues that could be addressed/improved:

  1. On JDKs later than 15, the javadoc machinery falls back to JDK 8, unless you explicitly call add-remote-javadoc for at least java. and javax.. This is a known issue that should be addressed in Clojure 1.13 per https://clojure.atlassian.net/browse/CLJ-2920 -- hopefully it will assume the URL structure for JDKs going forward so we don't run into this problem again, unless Oracle changes their URL structure again (hopefully, unlikely).

  2. javadoc-url is private so tools have to use #' to access it, which makes it feel like this is just an implementation detail and subject to change. It would be nice for tools if this was part of the public, documented API for clojure.java.javadoc.

  3. Inner classes are not handled well. If you ask for the javadoc-url for java.util.Map$Entry, you get a URL with Map$Entry.html which doesn't exist. Since inner classes are documented in their outer class, removing $[a-zA-Z0-9_]+ from the class name or from the URL would really help here.

Here's an example REPL session for Clojure 1.12.2 on JDK 24, showing these issues:

user=> (clojure-version) "1.12.2" user=> (require 'clojure.java.javadoc) nil user=> (#'clojure.java.javadoc/javadoc-url "java.util.concurrent.ExecutionException") "http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutionException.html" user=> (#'clojure.java.javadoc/javadoc-url "java.util.Map$Entry") "http://docs.oracle.com/javase/8/docs/api/java/util/Map$Entry.html" user=>

Please log in or register to answer this question.

...