In Java 9, the following combinations of modifiers are allowed on interfaces
https://bugs.openjdk.java.net/browse/JDK-8071453
"public static"
"public abstract"
"public default"
"private static"
"private"
"static" - same as "public static"
"abstract" - same as "public abstract"
"public" - same as "public abstract"
"" - same as "public abstract"
"default" - same as "public default"
Since Java 8, I've argued that the existing coding standards for
interfaces are now wrong.
http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-April/015803.html
http://blog.joda.org/2016/09/private-methods-in-interfaces-in-java-9.html
https://www.jfokus.se/jfokus17/preso/Java-SE-8-best-practices.pdf slide 75
What should be clear from the above list is that the first set of
modfiers are consistent, and match modifiers on classes. The second
set of modifiers are inconsistent, and require the developer to
remember that an absence of a modifier means package-scoped on a
class, but public on an interface. At this point, the different
meanings for an absence of modifier are just a confusing anachronism
in Java. So, this is not about methods lining up in a column, this is
about consistency across classes and interfaces, now that interfaces
are much more like classes.
Given the above, it should be clear why I want checkstyle to validate
that the modifiers are present in full on interfaces. At my day job
and in our major project Strata -
https://github.com/OpenGamma/Strata
- we use this coding standard for all interfaces. See this interface
for example which demonstrates the consistency of the cosing standard:
https://github.com/OpenGamma/Strata/blob/master/modules/basics/src/main/java/com/opengamma/strata/basics/date/DayCount.java#L29
I'm completely open to how the check is implemented in Checkstyle,
whether as part of RedundantModifier or a new check.
Stephen
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "checkstyle" group.
> To unsubscribe from this topic, visit
>
https://groups.google.com/d/topic/checkstyle/KYF-9EEzsbs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
>
checkstyle+...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.