Since Checkstyle 3.2
Rationale: Certain language features can harm readability, lead to confusion or are not obvious to novice developers. Other features may be discouraged in certain frameworks, such as not having native methods in Enterprise JavaBeans components.
name | description | type | default value | since |
---|---|---|---|---|
tokens | tokens to check | set of any supported tokens | LABELED_STAT . | 3.2 |
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="IllegalToken"/> </module> </module>
Example:
class Example1 { void InvalidExample() { outer: // violation, 'Using 'outer:' is not allowed' for (int i = 0; i < 5; i++) { if (i == 1) { break outer; } } } }
To configure the check to report violation on token LITERAL_NATIVE:
<module name="Checker"> <module name="TreeWalker"> <module name="IllegalToken"> <property name="tokens" value="LITERAL_NATIVE"/> </module> </module> </module>
Example:
class Example2 { native void InvalidExample(); // violation, 'Using 'native' is not allowed' }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.coding