redhat-developer / redhat-developer/vscode-java

Wrong reported errors by compiler

Open
#730 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have some pieces of code that compiles fine in IntelliJ and Gradle but VSCode reports them as errors.
Examples:

  1. Error in import

    import sun.security.ssl.ProtocolVersion;

screenshot 2018-11-30 at 11 46 27

I have to point that I'm not using the JVM in the error description. Here's my workspace's settings:

{
   "java.home": "/Users/augusto.dias/.sdkman/candidates/java/8.0.181-oracle",
   "java.jdt.ls.vmargs": "-javaagent:/Users/augusto.dias/my-project/.vscode/lombok.jar -Xbootclasspath/a:/Users/augusto.dias/my-project/.vscode/lombok.jar"
}
  1. Wrong exception handling

I have a RetryTemplate class from spring and I'm calling execute as the following example:

retryTemplate.execute(getCallback(),getRecovery());

private RetryCallback<Void, IOException> getCallback() {
    return context -> {
        if (context.getLastThrowable() instanceof IOException) {
                    IOException e = (IOException) context.getLastThrowable();
    // do some other things
                    throw e;
        }
        return null;
    };
}

private RecoveryCallback getRecovery() {
    return context -> {
        Throwable lastThrowable = context.getLastThrowable();
    // do some other things
        throw lastThrowable instanceof Exception ? (Exception) lastThrowable : new Exception(lastThrowable);
    }
}

screenshot 2018-11-30 at 13 54 27

  1. And finally: false error in method signature
    assertThat((List) ((Envelope) responseEntity.getBody()).getData(), hasItems(siteDTO));
    assertThat((List) ((Envelope) responseEntity.getBody()).getData(), hasSize(1));

screenshot 2018-11-30 at 13 57 43

Environment
  • Operating System: macOS Mojave
  • JDK version: 1.8
  • Visual Studio Code version: 1.29.1
  • Java extension version: 0.34.0

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 three reported diagnostics in the provided Java snippets using the workspace settings, JDK 1.8, VS Code 1.29.1, and Java extension 0.34.0. Compare the language-server results with IntelliJ and Gradle, then isolate whether each false error has the same cause. Done means the affected examples no longer produce incorrect diagnostics, with regression coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
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.