Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6764629

Lint option for redundant modifiers

    XMLWordPrintable

Details

    • x86
    • linux

    Description

      Request a compiler option -Xlint:redundantmodifiers which would issue warnings for any of the following cases:

      1. public on interface members (fields, methods, or types)

      2. static or final on interface fields

      3. abstract on interface methods

      4. static on interface type members

      5. static or abstract on interfaces themselves

      JLSv3 says that modifiers in these cases are redundant; and in some (but not all) of these cases states that use of the modifier is "strongly discouraged" for stylistic reasons.

      Regarding case #1, I know of one case where a NetBeans class was mistakenly made part of a public API due to its being nested in an interface. This mistake would have been less likely had javac consistently warned about using the public modifier on types nested in an interface, which would have reminded developers that such types are implicitly public - an otherwise little-known fact, I guess.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jglick Jesse Glick (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: