001: ////////////////////////////////////////////////////////////////////////////////
002: // Test case file for checkstyle.
003: // Created: 2001
004: ////////////////////////////////////////////////////////////////////////////////
005:
006: package com.puppycrawl.tools.checkstyle;
007:
008: /**
009: * Test case for Modifier checks:
010: * - order of modifiers
011: * - use of 'public' in interface definition
012: * @author lkuehne
013: */
014: strictfp final class InputModifier // illegal order of modifiers for class
015: {
016:
017: /** Illegal order of modifiers for variables */
018: static private boolean sModifierOrderVar = false;
019:
020: /**
021: * Illegal order of modifiers for methods. Make sure that the
022: * first and last modifier from the JLS sequence is used.
023: */
024: strictfp private void doStuff() {
025: }
026:
027: /** Single annotation without other modifiers */
028: @MyAnnotation2
029: void someMethod() {
030: }
031:
032: /** Illegal order of annotation - must come first */
033: private @MyAnnotation2
034: void someMethod2() {
035: }
036:
037: /** Annotation in middle of other modifiers otherwise in correct order */
038: private @MyAnnotation2
039: strictfp void someMethod3() {
040: }
041:
042: /** Correct order */
043: @MyAnnotation2
044: private strictfp void someMethod4() {
045: }
046:
047: /** Annotation in middle of other modifiers otherwise in correct order */
048: @MyAnnotation2
049: private static @MyAnnotation4
050: strictfp void someMethod5() {
051: }
052:
053: /** holder for redundant 'public' modifier check. */
054: public interface InputRedundantPublicModifier {
055: /** redundant 'public' modifier */
056: public void a();
057:
058: /** all OK */
059: void b();
060:
061: /** redundant abstract modifier */
062: abstract void c();
063:
064: /** redundant 'public' modifier */
065: public float PI_PUBLIC = (float) 3.14;
066:
067: /** redundant 'abstract' modifier (field can not be absract)*/
068: // abstract float PI_ABSTRACT = (float) 3.14;
069: /** redundant 'final' modifier */
070: final float PI_FINAL = (float) 3.14;
071:
072: /** all OK */
073: float PI_OK = (float) 3.14;
074: }
075:
076: /** redundant 'final' modifier */
077: private final void method() {
078: }
079: }
080:
081: /** Holder for redundant 'final' check. */
082: final class RedundantFinalClass {
083: /** redundant 'final' modifier */
084: public final void finalMethod() {
085: }
086:
087: /** OK */
088: public void method() {
089: }
090: }
091:
092: /** Holder for redundant modifiers of inner implementation */
093: interface InnerImplementation {
094: InnerImplementation inner = new InnerImplementation() {
095: /** compiler requires 'public' modifier */
096: public void method() {
097: }
098: };
099:
100: void method();
101: }
102:
103: /** Holder for redundant modifiers of annotation fields/variables */
104: @interface Annotation {
105: public String s1 = "";
106: final String s2 = "";
107: static String s3 = "";
108: String s4 = "";
109:
110: public String blah();
111:
112: abstract String blah2();
113: }
114:
115: @interface MyAnnotation2 {
116: }
117:
118: @interface MyAnnotation4 {
119: }
|