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

Field is shown as unused if only used in annotation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.0
    • None
    • java - Editor
    • None

    Description

      When a private static final field is only used as an annotation parameter, the editor marks it as "not used". Example:

      public class Example
      {
          @SuppressWarnings(FOO)
          public void foo() { }
          
          private static final String FOO = "FOO";
      }
      

      Here the field FOO will be highlighted as unused in its declaration, with a tooltip "Field FOO not used".

      My actual use-case is @JsonProperty annotations that occur both on constructor parameters and on getters, hence each property name string occurs multiple times, so
      it is useful to define psf constants for those names. But it is irritating that they are all marked as unused by the editor.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: