Skip to content

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

Closed

Description

@Laceprndpm

[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

Activity

  1. rgrunber commented on Oct 3, 2024

    @rgrunber
    Member

    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.

  2. rgrunber commented on Oct 3, 2024

    @rgrunber
    Member

    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 ?
  3. Laceprndpm commented on Oct 5, 2024

    @Laceprndpm
    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!
  4. fp024 commented on Oct 6, 2024

    @fp024

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

  5. snjeza commented on Oct 6, 2024

    @snjeza
    Collaborator
  6. fp024 commented on Oct 6, 2024

    @fp024

    @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. 😊👍

  7. snjeza commented on Oct 6, 2024

    @snjeza
    Collaborator

    This is an upstream JDT issue. JDT sometimes doesn't initialize indexes properly.
    eclipse-jdtls/eclipse.jdt.ls#3296 fixes it.

  8. rgrunber commented on Oct 7, 2024

    @rgrunber
    Member

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

  9. snjeza commented on Oct 7, 2024

    @snjeza
    Collaborator
  10. moved this to 📝 In Progress in IDE Cloudaptorson Oct 8, 2024
  11. moved this from 📝 In Progress to 👀 In review in IDE Cloudaptorson Oct 8, 2024
  12. self-assigned this
    on Oct 9, 2024
  13. assigned and unassigned on Oct 9, 2024
  14. added this to the End October 2024 milestone on Oct 16, 2024
  15. Laceprndpm commented on Oct 16, 2024

    @Laceprndpm
    Author

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

  16. mozhuanzuojing commented on Oct 16, 2024

    @mozhuanzuojing
    Contributor

    The long-standing problem has finally been solved

  17. fp024 commented on Oct 17, 2024

    @fp024

    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

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions