Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent Class Loading Issues with Java Core Packages in VSCode #3797

Closed
Laceprndpm opened this issue Oct 3, 2024 · 13 comments
Closed

Comments

@Laceprndpm
Copy link

[provide a description of the issue]

Environment
  • Operating System:Win 11
  • JDK version:JDK 17
  • Visual Studio Code version:1.93.1
  • Java extension version:v1.35.1
Steps To Reproduce

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.
issue

[Please attach a sample project reproducing the error]
Please attach logs

Current Result
Expected Result
Additional Informations
@rgrunber
Copy link
Member

rgrunber commented 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
Copy link
Member

rgrunber commented Oct 3, 2024

Some things to try :

  • At the bottom left corner, there should be a Java status icon. Is it in the "Ready" state ?
    image
  • At the bottom right corner there should be a Java language mode icon. Does it clearly indicate a Java execution environment version ?
    image
  • 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 ?

@Laceprndpm
Copy link
Author

  • Yes,Regardless of whether it is working normally or abnormally, the status in the bottom left is always 'Ready'.
    3499AD50172C8CDC156BEBDEFDA30A8A
  • Yes.
    73EF408DBF39CFD4AFFBAE138A82B621
  • 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.
    FA7667B51E83C40B367890101405F9E4
  • 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.
    1EEDB5712EBCE2D27ECB88970737670B
    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
Copy link

fp024 commented 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:

  • 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.
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:

  • v1.18.0
  • v1.20.0
  • v1.21.0
  • v1.22.0

Versions where Java standard library import suggestions start to occasionally fail:

  • v1.22.1
  • v1.23.0
  • v1.24.0

💡 It seems that the regression issue might have started occurring when upgrading from v1.22.0 to v1.22.1.

@snjeza
Copy link
Contributor

snjeza commented Oct 6, 2024

@fp024 Could you, please, check https://github.com/snjeza/vscode-test/raw/refs/heads/master/java-1.37.0.vsix ?

@fp024
Copy link

fp024 commented 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
Copy link
Contributor

snjeza commented 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
Copy link
Member

rgrunber commented Oct 7, 2024

@snjeza , do you know when this started happening upstream ? Are they aware of this ?

@snjeza
Copy link
Contributor

snjeza commented 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
Copy link
Member

rgrunber commented Oct 7, 2024

@Laceprndpm
Copy link
Author

Thanks! After installing the file, the import suggestion issues no longer occur. This has been very helpful!

@mozhuanzuojing
Copy link

The long-standing problem has finally been solved

@fp024
Copy link

fp024 commented Oct 17, 2024

Studying Java with vscode-java has become fun again. Thanks for the support. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

5 participants