Issue #3471: Fix order of "default" method modifier
This commit is contained in:
parent
a3d8d12717
commit
4691d52517
|
|
@ -97,6 +97,7 @@ public class ModifierOrderTest extends BaseCheckTestSupport {
|
|||
"215:28: " + getCheckMessage(clazz, msgMod, "synchronized"),
|
||||
"217:37: " + getCheckMessage(clazz, msgMod, "protected"),
|
||||
"219:22: " + getCheckMessage(clazz, msgAnnotation, "@MyAnnotation2"),
|
||||
"245:14: " + getCheckMessage(clazz, msgMod, "default"),
|
||||
};
|
||||
|
||||
final Configuration checkConfig = getCheckConfig("ModifierOrder");
|
||||
|
|
|
|||
|
|
@ -236,3 +236,11 @@ class WithInner
|
|||
|
||||
@interface MyAnnotation4 {
|
||||
}
|
||||
|
||||
/** Illegal order of modifiers for interface methods */
|
||||
interface InputModifierOrderInterface
|
||||
{
|
||||
default strictfp void a() { } //ok
|
||||
|
||||
strictfp default void b() { } //warn
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
|||
|
||||
<li><span class="code">private</span></li>
|
||||
<li><span class="code">abstract</span></li>
|
||||
<li><span class="code">default</span></li>
|
||||
<li><span class="code">static</span></li>
|
||||
<li><span class="code">final</span></li>
|
||||
<li><span class="code">transient</span></li>
|
||||
|
|
@ -84,8 +85,8 @@ public class ModifierOrderCheck
|
|||
* 8.3.1 and 8.4.3 of the JLS.
|
||||
*/
|
||||
private static final String[] JLS_ORDER = {
|
||||
"public", "protected", "private", "abstract", "static", "final",
|
||||
"transient", "volatile", "synchronized", "native", "strictfp", "default",
|
||||
"public", "protected", "private", "abstract", "default", "static",
|
||||
"final", "transient", "volatile", "synchronized", "native", "strictfp",
|
||||
};
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public class ModifierOrderCheckTest
|
|||
"34:13: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@MyAnnotation2"),
|
||||
"39:13: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@MyAnnotation2"),
|
||||
"49:35: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@MyAnnotation4"),
|
||||
"157:14: " + getCheckMessage(MSG_MODIFIER_ORDER, "default"),
|
||||
};
|
||||
verify(checkConfig, getPath("InputModifier.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,4 +143,18 @@ enum TestEnum {
|
|||
|
||||
public void method() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** holder for interface specific modifier check. */
|
||||
interface InputDefaultPublicModifier
|
||||
{
|
||||
/** correct order */
|
||||
default strictfp void a()
|
||||
{
|
||||
}
|
||||
|
||||
/** wrong order */
|
||||
strictfp default void b() // violation
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@
|
|||
Checks that the order of modifiers conforms to the suggestions in
|
||||
the <a
|
||||
href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html">Java
|
||||
Language specification, sections 8.1.1, 8.3.1 and 8.4.3</a>. The
|
||||
correct order is:
|
||||
Language specification, sections 8.1.1, 8.3.1, 8.4.3</a> and <a
|
||||
href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html">
|
||||
9.4</a>. The correct order is:
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
|
|
@ -44,6 +45,9 @@
|
|||
<li>
|
||||
<code>abstract</code>
|
||||
</li>
|
||||
<li>
|
||||
<code>default</code>
|
||||
</li>
|
||||
<li>
|
||||
<code>static</code>
|
||||
</li>
|
||||
|
|
|
|||
Loading…
Reference in New Issue