redhat-developer / redhat-developer/vscode-java

Reference to classes with private constructor not resolved

Open
#3,953 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

I have a class implementing singleton pattern:

public class SomeSingleton {
  private static SomeSingleton uniqueInstance = null;
  private SomeSingleton() {}
  
  @Synchronized
  public static SomeSingleton getInstance() {
    if (uniqueInstance == null) 
     uniqueInstance = new SomeSingleton();
    return uniqueInstance;
  }

  public void someMethod() {}
}

Any reference to SomeSingleton.getInstance().someMethod() in the editor is underlined in red as error:
SomeSingleton cannot be resolved to a type Java(16777218)

The code build fine with gradle from the command line, without any errors.

My vscode setup:

Version: 1.97.2 (system setup)
Commit: e54c774e0add60467559eb0d1e229c6452cf8447
Date: 2025-02-12T23:20:35.343Z
Electron: 32.2.7
ElectronBuildId: 10982180
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.26100

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the diagnostic in VS Code with the singleton example and a Gradle project on Windows. Compare the editor's Java language-server resolution with the successful command-line build. Done means the reference no longer shows “SomeSingleton cannot be resolved to a type” while the project continues to build successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.