Vscode-java: Code Navigation for dependencies

Created on 25 May 2018  路  11Comments  路  Source: redhat-developer/vscode-java

I have a Spring based project and when I try to Ctrl-click to see the source code for a Spring class I get the "Failed to get sources. Instead, stub sources have been generated by the disassembler. Implementation of methods is unavailable." message. I have the sources in my local gradle repo and am wondering how I can get these configured to be able to navigate to the source? I guess the same issue is keeping javadocs for the Spring libraries to be shown also?

Environment
  • Operating System: Windows 10
  • JDK version: 1.8.0_144
  • Visual Studio Code version: 1.23.0
  • Java extension version: 0.25.0
Steps To Reproduce
  1. Load java source with Spring classes being used
  2. Ctrl-click on a Spring class

[attach a sample project reproducing the error]
[attach logs](https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#enable-logging)

Current Result
Expected Result
Additional Informations
Gradle

Most helpful comment

I am using "openjdk-8-jdk" package in debian.

Installing "openjdk-8-source" and restarting vscode fixed the issue for me.

Thanks for suggesting "a JDK that does not ship the sources".

(Hay谋rl谋 Ramazanlar)

All 11 comments

Most likely, the sources are still being downloaded in the background. Try reopening the project to see if you still see the issue

Hi, if it helps,

I can navigate to maven dependency sources, but not to JDK sources.

For example,
I can see the source of Spring's MongoTemplate, but not Java's ConcurrentLinkedQueue.

This is probably an indication that your default Java runtime is either a JRE instead of JDK or a JDK that does not ship the sources. Can you check your JAVA_HOME value and see where it points to?

I am using "openjdk-8-jdk" package in debian.

Installing "openjdk-8-source" and restarting vscode fixed the issue for me.

Thanks for suggesting "a JDK that does not ship the sources".

(Hay谋rl谋 Ramazanlar)

I have the similar question,
OS: Ubuntu 18.04
JDK version: 11.04

I configured JAVA_HOME system environment variable, I also installed openjdk-11-source. But if I want to jump to the definition of Class in standard java library, I always get:
// Failed to get sources. Instead, stub sources have been generated by the disassembler.
// Implementation of methods is unavailable.

I had same case:

When trying to open any JDK class source, the following stacktrace appeared in "Ouput" tab in VS Code:

[Error - 2:24:12 PM] Request textDocument/documentSymbol failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.NullPointerException
    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.NullPointerException
    at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.getRange(DocumentSymbolHandler.java:174)
    at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.toDocumentSymbol(DocumentSymbolHandler.java:148)
    at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.lambda$2(DocumentSymbolHandler.java:127)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.getHierarchicalOutline(DocumentSymbolHandler.java:127)
    at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.documentSymbol(DocumentSymbolHandler.java:72)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$13(JDTLanguageServer.java:557)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$26(JDTLanguageServer.java:764)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
    ... 6 more

Other info:

  • Language Support for Java plugin v 0.33.0
  • Ubuntu 18.10 , JDK 11, sudo apt install openjdk-11-source is installed as well.
  • No error, no warning in ~/.config/Code/User/workspaceStorage/1051a_longHash_d8d0a3c/redhat.java/jdt_ws/.metadata/.log
  • disabled gradle setting (aka "java.import.gradle.enabled": false )
  • removed workspace as well (aka https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#clean-the-workspace-directory )

@matihost you can try the solution I found in this thread
https://github.com/redhat-developer/vscode-java/issues/689#issuecomment-434046529

Thanks @praenubilus it helped
I posted your workaround to Ubuntu bug:
https://bugs.launchpad.net/ubuntu/+source/openjdk-lts/+bug/1791219:
Symbolic link to src.zip in openjdk-11-source points to an invalid location.

However NPE is NPE, the plugin should at least warn that source were not found under particular location.

@matihost It's really annoying. Everytime apt update including openjdk will overwrite the manually created symbolink to the incorrect one again.

I am using "openjdk-8-jdk" package in debian.

Installing "openjdk-8-source" and restarting vscode fixed the issue for me.

Thanks for suggesting "a JDK that does not ship the sources".

(Hay谋rl谋 Ramazanlar)

Thanx that helps)

@matihost you can try the solution I found in this thread
#689 (comment)

The root cause is apt creates wrong symbol link and making the sources missing. And this bug can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ViniciusAtaide picture ViniciusAtaide  路  4Comments

bkbonner picture bkbonner  路  3Comments

zalcorshark picture zalcorshark  路  3Comments

BuZZ-dEE picture BuZZ-dEE  路  4Comments

joewood picture joewood  路  3Comments