Skip to content

Javadoc support for referencedLibraries? #2984

Description

@Hexorg

If a non-maven/gradle library is added to referencedLibraries config (added by #1196) - it is impossible to add the library's javadoc.

Environment
  • Operating System: Tried OSX and Gentoo Linux.
  • JDK version: 19
  • Visual Studio Code version: 1.76.0
  • Java extension version: v0.25.8
Steps To Reproduce
  1. Download any library from maven, e.g. https://repo1.maven.org/maven2/com/pelzer/util/pelzer-util/1.9.0/pelzer-util-1.9.0.jar and https://repo1.maven.org/maven2/com/pelzer/util/pelzer-util/1.9.0/pelzer-util-1.9.0-javadoc.jar
  2. Delete META-INF/maven from the jar
  3. Add two jars as referenced libraries to settings.json
  4. Import a class and hover over it or ctrl+click on it. Only bare decompiler structure shows up without documentation.
Current Result

Import a class and hover over it or ctrl+click on it. Only bare decompiler structure shows up without documentation.

Expected Result

Ability to map javadoc jars to libraries to allow for javadoc presentation on hover.

Activity

  1. github-actions commented on Mar 7, 2023

    @github-actions

    We have found issues that are potential duplicates:

    If any of the issues listed above are a duplicate, please consider closing this issue & upvoting/commenting the original one.
    Alternatively, if neither of the listed issues addresses your feature/bug, keep this issue open.

  2. jdneo commented on Mar 8, 2023

    @jdneo
    Collaborator

    By default, a referenced {binary}.jar will try to search {binary}-sources.jar under the same directory, and attach it as source if one match is found.

    If you want to manually specify a JAR file as a source attachment, you can provide a key-value map in the sources field:

    "java.project.referencedLibraries": {
        "include": [
            "library/**/*.jar",
            "/home/username/lib/foo.jar"
        ],
        "exclude": [
            "library/sources/**"
        ],
        "sources": {
            "library/bar.jar": "library/sources/bar-src.jar"
        }
    }
    

    In this way, bar-src.jar is attached to bar.jar as its source.

  3. Hexorg commented on Mar 8, 2023

    @Hexorg
    Author

    Yeah it seems some commenters on stack overflow are confused about sources vs compiled javadoc as I found plenty of people say that VSCode can display javadoc, while in reality it would just read the manifest and download sources in the background.

  4. fbricon commented on Mar 8, 2023

    @fbricon
    Collaborator

    We found it simpler to handle both sources and javadoc from a single (source) jar file.

    We could very well add similar support for *-javadoc.jar, but I don't think this will be used that much.

  5. jdneo commented on Mar 9, 2023

    @jdneo
    Collaborator

    @Hexorg My bad, I misunderstood your problem.

  6. Hexorg commented on Mar 9, 2023

    @Hexorg
    Author

    Thanks everyone! I guess overall, I found a workaround by mapping sources to binaries. I didn’t know “sources” key mapping existed in the config before I made this ticket. At the same time javadoc jars are still ignored so I don’t know if you want me to close this ticket or keep it open.

  7. ddemange commented on Sep 29, 2026

    @ddemange

    Being able to handle binary + javadoc jars without requiring the source jar would be very useful indeed.

    I find it surprising that vscode-java doesn't include that possibility.

    Situations where you don't want to disclose java sources are frequent.
    If people are willing to distribute their sources, I no longer even understand why classes would remain useful to distribute altogether, as well as javadocs.

    I am probably missing something.

    Is this issue still alive ? That would be great.
    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions