redhat-developer / redhat-developer/vscode-java

Add Xlint Support

Open
#3,108 0 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

My apologies in advance if this feature is already supported/implemented and I could not find it.

This extension does an excellent job of reporting most warnings, but recently I came across several warnings in my project that this extension was not reporting but I found through compiling with the -Xlint flag.

Take this SSCCE for example:

public class Test
{
    public static void main(String[] args)
    {
        int x = 3;
        int y = (int)x;

        System.out.println(y);
    }
}

This code runs perfectly fine with this extension with no warnings, but if you compile it with javac -Xlint Test.java, you will get this:

Test.java:6: warning: [cast] redundant cast to int
        int y = (int)x;
                ^      
1 warning

This is just one example but it seems there are other types of useful warnings that the Xlint flag gives that this extension does not report, such as not marking non-serializable fields as transient.

I understand the Xlint flag is comprised of many subflags (search for Xlint on this man page to see the options) that can be turned on and off to report or ignore different types of warnings, and users may not want to see all the warnings that -Xlint:all reports. Thus, it would nice for these additional warnings to not only be supported, but for the user to have the option to turn these individual warning categories on or off as you can when manually compiling your project.

My thanks in advance for your help!

Environment
  • Operating System: Windows 10
  • JDK version: 17.0.4.1
  • Visual Studio Code version: 1.78.2
  • Java extension version: 1.19.2023052004

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 tracing how the extension invokes javac and surfaces compiler warnings; the issue names no repository files, tests, or entry points. Use the provided Test.java example and javac -Xlint behavior as references, and define done as supporting the requested Xlint warning categories with user-configurable enablement.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.