Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-5379

Warning hint "Unused Element" can't be suppressed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.2
    • None
    • java - Hints
    • None

    Description

      The hint "Unused Element" (category "Probably Bugs") can't be suppressed, it seems. In particular, @SuppressWarnings("unused") doesn't suppress it.

      One concrete use case I have is a try-with-resources where the resource variable is not used in the try block. (Of course, it is implicitly used for close()-ing the resource.) NetBeans generates a warning (which is fine, the code could indeed be wrong) which however can't be suppressed. Previously (last tested in 12.0), @SuppressWarnings("try") would do the trick.

      This isn't the first time a warning hint was introduced without a way to suppress it. I'd like to suggest to always, as a rule, without exception, add a suppression constant, because there are invariably cases where a warning is a false positive.

      Attachments

        Activity

          People

            Unassigned Unassigned
            matthies Niklas Matthies
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: