Skip to content

Cannot show javadoc of core JDK classes on JDK 9+ #2687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jumarko opened this issue Aug 9, 2019 · 10 comments
Closed

Cannot show javadoc of core JDK classes on JDK 9+ #2687

jumarko opened this issue Aug 9, 2019 · 10 comments
Labels
bug help wanted high priority Tickets of particular importance

Comments

@jumarko
Copy link

jumarko commented Aug 9, 2019

UPDATE 2: for now, there seem to be consistent issues with at least:

  • cider-javadoc -> adds an extra "java.base" javadoc url path segment which leads to 404 NOT FOUND error
  • cider-doc doesn't show proper javadoc for newer(?) JDK classes (e.g. java.lang.Module)

UPDATE: It must be something in my ./lein/profiles.clj - when I remove them it works. I'll try to find out what's causing that.

I can't display javadoc for core classes like java.lang.String even though JDK sources are available.

It works when I use JDK 8.
If I use anything more recent (tested with JDK 9 and 11) then it doesn't work.

Perhaps related to #2686

Expected behavior

When invoking cider-javadoc the javadoc for the String class should be displayed:

image

Actual behavior

Javadoc is not shown:
image

Steps to reproduce the problem

  • set java version to JDK 11 (perhaps using jenv)
  • run cider-jack-in
  • type String into the REPL/buffer and try to show javadoc

Environment & Version information

CIDER version information

CIDER 0.22.0snapshot (package: 20190808.1659), nREPL 0.6.0
Clojure 1.10.1, Java 11.0.2

Lein/Boot version

lein -v
Leiningen 2.9.1 on Java 11.0.2 OpenJDK 64-Bit Server VM

Emacs version

25.3.1

Using Spacemacs

image

Operating system

Mac OS X 10.14.5

@bbatsov
Copy link
Member

bbatsov commented Aug 9, 2019

UPDATE: It must be something in my ./lein/profiles.clj - when I remove them it works. I'll try to find out what's causing that.

What's in your profiles? //cc @jeffvalk

@jumarko
Copy link
Author

jumarko commented Aug 10, 2019

There are quite a few things in my profiles.clj although I commented out many of them yesterday. The current version is here: https://github.com/jumarko/clojure-experiments/blob/master/lein-profiles.clj.

Unfortunately, I'm now not so sure that it's completely caused by the presence of profiles.clj.
It seems that it works even when I'm using my current profiles.clj (at least on https://github.com/jumarko/lein-sample) for things like java.lang.String or java.lang.Number.
However, it doesn't seem to work for newer classes like java.lang.Module.

Moreover, the cider-javadoc seems to be broken for (at least) JDK 11.
clojure.java.javadoc/javadoc works without problems; e.g.

(javadoc String)
;;=> opens proper docs: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html

However, invoking cider-javadoc yields https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java.base/java/lang/String.html which returns NOT FOUND (extra "java.base" segment in the middle of the URL path)

@bbatsov
Copy link
Member

bbatsov commented Aug 11, 2019

Hmm, that's pretty weird as we actually have a bunch of unit tests for URLs for different JDK versions - see https://github.com/clojure-emacs/orchard/blob/master/test/orchard/java_test.clj#L199

@jeffvalk
Copy link
Contributor

Regarding the original issue: Is there anything at play that would affect classloaders?

The JDK sources are dynamically loaded by orchard.java; if something causes src.zip to be loaded by a classloader that is too low in the hierarchy, its contents won't be visible on the classpath when orchard.java.parser looks for a particular class' source file. (This is only a potential issue on JDK9+; prior to that, classloaders at the top of the hierarchy were de facto dynamic.)

@jumarko
Copy link
Author

jumarko commented Aug 12, 2019

@bbatsov those tests look correct but I think the problem is in the info/javadoc-info function which is called on the result and that adds the extra "java.base" segment to the url path in the resolve-javadoc-function.

More specifically, when I tested it with "java.base/java/util/Random.html#nextLong()" it went to the path of dereferencing the javadoc/*remote-javadocs* which for *core-java-api* returns and JDK 11 returns this url: "https://docs.oracle.com/en/java/javase/11/docs/api/java.base/" - notice that "java.base" prefix is already there:

orchard.info> (javadoc-info "java.base/java/util/Random.html#nextLong()")
;;=>
{:javadoc
"https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java.base/java/util/Random.html#nextLong()"}

@jumarko jumarko changed the title Cannot show javadoc or jump to the source of core JDK classes on JDK 9+ Cannot show javadoc of core JDK classes on JDK 9+ Aug 12, 2019
@jumarko
Copy link
Author

jumarko commented Aug 12, 2019

@jeffvalk
I'm not sure I can answer your question.
But perhaps it's more related to #2686 ?

I've updated the description to state two things (cider-javadoc not working for JDK 11 and cider-doc not working for classes like java.lang.Module).
I'd say let's ignore my issues with cider-doc and core java.lang classes (at least until I can figure out what exactly is causing the issues or come up with a solid reproducer).

@jeffvalk
Copy link
Contributor

jeffvalk commented Aug 12, 2019

notice that "java.base" prefix is already there

That appears to be true, and hence broken. clojure.java.javadoc/*remote-javadocs* returns wrong URLs for any JDK class not in the java.base module. This includes a lot of common classes (e.g. java.sql.*, java.util.logging.*, etc).

If we want correct URLs, it seems we shouldn't rely on what clojure.java.javadoc currently supplies.

@bbatsov
Copy link
Member

bbatsov commented Aug 15, 2019

Yeah, I think we should just replicate this in orchard. I think this will be pretty simple. Might also be a good idea to open an upstream issue report in Clojure.

@jumarko
Copy link
Author

jumarko commented Aug 15, 2019

Asked for clarification of the upstream lib behavior here: https://ask.clojure.org/index.php/8422/clojure-javadoc-javadoc-fails-javadoc-classes-outside-module

@dpsutton
Copy link
Contributor

clojure-emacs/orchard#84

fixes this. I've also got a jira ticket to add a doc url for java 13. Can add a backport for this while we wait if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted high priority Tickets of particular importance
Projects
None yet
Development

No branches or pull requests

4 participants