Details
-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
5.0
-
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.
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.