You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Intermittent Class Loading Issues with Java Core Packages in VSCode #3797
1.While using the Java extension in VSCode, I encountered an issue where the classes from the Java core packages (such as String) cannot be loaded correctly, which leads to malfunctioning autocomplete features. However, even though these core package classes fail to load, I am still able to use methods from the String class, such as String.length() and String.substring(), which work properly and provide autocomplete. Moreover, this issue does not occur every time.
[Please attach a sample project reproducing the error] Please attach logs
Update: Ok there's some slight differences. In that issue, basic JDK classes also didn't resolve. Here they seem to be resolving, just completion isn't showing them at all.
At the bottom left corner, there should be a Java status icon. Is it in the "Ready" state ?
At the bottom right corner there should be a Java language mode icon. Does it clearly indicate a Java execution environment version ?
Are there any errors in the problems view ? Maybe relating to the import of the project ?
If you go to the command palette and call the command Java: Open Java Language Server Log File, are there any errors/something strange being logged around the time this occurs ?
If you bring up the workspace symbol search (ctrl + t or Go -> Go To Symbol In Workspace), are you able to search for the "String" type, or any other types on the classpath ?
Yes,Regardless of whether it is working normally or abnormally, the status in the bottom left is always 'Ready'.
Yes.
Considering that I just started learning programming, the only package I imported is algs4.jar, and I don't believe this would cause import errors. To be safe, I deleted this package, but I still can't load the core packages.
In the log file, I did not see any instances of 'error' or 'warning'.
When I open VSCode, the autocomplete feature works normally and can load core packages. However, once I perform any action, such as switching to another program (like Firefox) or pressing Ctrl + T, the autocomplete feature becomes inactive and is no longer usable.So,I didn't find anything.
I used ChatGPT for translation, so there may be unclear expressions.
If you need any further clarification or additional information, please feel free to reach out to me. I appreciate your understanding!
In the past, I don’t recall experiencing import suggestion issues, so I checked older versions.
Checked import suggestion functionality with Map, List, Set, SimpleDateFormat, LocalDateTime, etc.
Method to check suggestion functionality:
Turn off and restart VSCode. Once the project is fully loaded, check the import suggestions. Repeat this process about 10 times to ensure there are no issues.
I did not execute Clean Java Language Server Workspace.
Activity
rgrunber commentedon Oct 3, 2024
Seems really similar to #3793 .
Update: Ok there's some slight differences. In that issue, basic JDK classes also didn't resolve. Here they seem to be resolving, just completion isn't showing them at all.
rgrunber commentedon Oct 3, 2024
Some things to try :
Java: Open Java Language Server Log File, are there any errors/something strange being logged around the time this occurs ?Laceprndpm commentedon Oct 5, 2024
I used ChatGPT for translation, so there may be unclear expressions.
If you need any further clarification or additional information, please feel free to reach out to me. I appreciate your understanding!
fp024 commentedon Oct 6, 2024
@rgrunber
In the past, I don’t recall experiencing import suggestion issues, so I checked older versions.
Checked import suggestion functionality with Map, List, Set, SimpleDateFormat, LocalDateTime, etc.
Method to check suggestion functionality:
Clean Java Language Server Workspace.v1.22.0-work-well-mute.mp4
v1.22.1-dose-not-work-mute.mp4
Versions where there are no issues with Java standard library import suggestions:
Versions where Java standard library import suggestions start to occasionally fail:
💡 It seems that the regression issue might have started occurring when upgrading from v1.22.0 to v1.22.1.
snjeza commentedon Oct 6, 2024
@fp024 Could you, please, check https://github.com/snjeza/vscode-test/raw/refs/heads/master/java-1.37.0.vsix ?
fp024 commentedon Oct 6, 2024
@snjeza
I manually installed the file from the link and confirmed it.
I checked it about 10 times, and the import suggestion issues did not occur. 😊👍
snjeza commentedon Oct 6, 2024
This is an upstream JDT issue. JDT sometimes doesn't initialize indexes properly.
eclipse-jdtls/eclipse.jdt.ls#3296 fixes it.
rgrunber commentedon Oct 7, 2024
@snjeza , do you know when this started happening upstream ? Are they aware of this ?
snjeza commentedon Oct 7, 2024
The issue doesn't happen in Eclipse because of https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/8f8fafd02eac6cf56c98d5941ab5df1a4460eb3e/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java#L419
rgrunber commentedon Oct 7, 2024
So it's specifically :
https://github.com/eclipse-jdt/eclipse.jdt.core/blob/55d99cde490111cad4874bc05eec03397ca5bc0e/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java#L4798-L4809
https://github.com/eclipse-jdt/eclipse.jdt.core/blob/55d99cde490111cad4874bc05eec03397ca5bc0e/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java#L4816-L4819
?
Laceprndpm commentedon Oct 16, 2024
Thanks! After installing the file, the import suggestion issues no longer occur. This has been very helpful!
mozhuanzuojing commentedon Oct 16, 2024
The long-standing problem has finally been solved
fp024 commentedon Oct 17, 2024
Studying Java with vscode-java has become fun again. Thanks for the support. 👍