vscode-java
vscode-java copied to clipboard
Code Navigation for dependencies
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
- Load java source with Spring classes being used
- Ctrl-click on a Spring class
[attach a sample project reproducing the error] attach logs
Current Result
Expected Result
Additional Informations
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.
I have encountered a similar problem. Not quite sure if my issue is the same, but after doing mvn compile exec:java
mentioned in the Shiro's tutorial on shiro-1.8.0, I get this same error message at the top of the class "org.apache.shiro.config.IniSecurityManagerFactory" (i.e.: //Failed to get sources. Instead, stub sources have been generated by the disassembler). Now when importing this class, it gets crossed out by the vscode and intellisense says: "The type IniSecurityManagerFactory is deprecated", while I'm using the latest version of the Shiro.
Hi, I was also facing the same issue where when I hover over a function from core java the docs were appearing but when I hovered over a function that came as a part of maven dependency, nothing was showing up.
What is the issue?
sources and javadoc was not getting downloaded when a java/maven project was getting loaded
What is the solution?
after setting below two configurations in VS Code settings.json file the VS Code downloads the sources and javadoc while loading a java/maven project
"java.eclipse.downloadSources": true,
"java.maven.downloadSources": true,
See the extra steps followed for downloading and associating sources and javadoc in below screenshot:
What is the result of all this?
Where can we find setting.json file for VS Code?
Press ctrl+shift+p
on windows and search for settings, you should see a Preferences: Open Settings (JSON)
as shown in below screenshot:
Hope it helps 🙂
Close as the problem is resolved.