Imports for Java packages
Imports for Java packages such as java.util.* or java.time.* are no longer suggested or added in the Code Editor.
Environment
- Operating System: Win10Pro
- JDK version: 21
- Visual Studio Code version: 1.92.2
- Java extension version: Extension Pack for Java v0.29.0
Steps To Reproduce
- open *.java file
- type LocalDateTime
Only imports from third-party libraries are offered, e.g com.fasterxml... or com.springframework...
Do you see any other errors in the problems view, or just the ones about those imports not being found ? Seems like a misconfigured JDK might cause this, given that you're still seeing import suggestions from other 3rd party libraries.
I've been having this problem on & off while now. When it happens I run the "Clean Java Language Server Workspace" command which sorts it out. Nothing obvious in the Problem / Output panels.
Environment
- Operating System: Windows 11 Pro
- JDK version: 17
- Visual Studio Code version: 1.92.2
- Java extension version: Extension Pack for Java v0.29.0 (Language support v1.34.0)
Ill have a play around to see if I can figure out what is triggering the issue.
Duplicate of https://github.com/redhat-developer/vscode-java/issues/3715
I almost expected the reaction to be a misconfigured JDK. But that is not the case. The projects work and can be compiled and executed. I can't find anything about this in the problems view.
Yeah it definitely seems like #3715 . I've run into it once or twice before, and also found it went away when I cleaned the workspace. I saved my client/server logs from around when this happened and can clearly see the imports not being sent back during that period of time. However there isn't anything odd in terms of errors. Just that the server completely left out the code actions regarding imports but did include others (so it wasn't an outright failure).
I also have this issue where the java.util.* package is not being suggested, which is quite frustrating. It happens from time to time, and I have to restart VSCode or clear the cache. When will this issue be fixed? Environment Operating System: macOS 14.6.1 JDK version: 21 Visual Studio Code version: 1.93.0 Java extension version: Extension Pack for Java v0.29.0
I would try the vscode-java pre-release build tomorrow. There's a good chance this has been fixed now.
Marking as closed as I really think this was fixed in https://github.com/redhat-developer/vscode-java/issues/3797 (or even #3715 , there were many duplicates of the same problem).