1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   // Created: 2001
4   ////////////////////////////////////////////////////////////////////////////////
5   
6   package com.puppycrawl.tools.checkstyle.checks.sizes.methodlength;
7   
8   strictfp final class InputMethodLengthModifier
9   {
10  
11      /** Illegal order of modifiers for variables */
12      static private boolean sModifierOrderVar = false;
13  
14      /**
15       * Illegal order of modifiers for methods. Make sure that the
16       * first and last modifier from the JLS sequence is used.
17       */
18      strictfp private void doStuff()
19      {
20      }
21  
22      /** Single annotation without other modifiers */
23      @MyAnnotation2 void someMethod()
24      {
25      }
26  
27      /** Illegal order of annotation - must come first */
28      private @MyAnnotation2 void someMethod2()
29      {
30      }
31  
32      /** Annotation in middle of other modifiers otherwise in correct order */
33      private @MyAnnotation2 strictfp void someMethod3()
34      {
35      }
36  
37      /** Correct order */
38      @MyAnnotation2 private strictfp void someMethod4()
39      {
40      }
41  
42      /** Annotation in middle of other modifiers otherwise in correct order */
43      @MyAnnotation2 private static @MyAnnotation4 strictfp void someMethod5()
44      {
45      }
46  
47      /** holder for redundant 'public' modifier check. */
48      public static interface InputRedundantPublicModifier // violation
49      {
50          /** redundant 'public' modifier */
51          public void a(); // violation
52  
53          /** all OK */
54          void b();
55  
56          /** redundant abstract modifier */
57          abstract void c(); // violation
58  
59          /** redundant 'public' modifier */
60          public float PI_PUBLIC = (float) 3.14; // violation
61  
62          /** redundant 'abstract' modifier (field can not be abstract) */
63  //        abstract float PI_ABSTRACT = (float) 3.14;
64  
65          /** redundant 'final' modifier */
66          final float PI_FINAL = (float) 3.14; // violation
67  
68          /** all OK */
69          float PI_OK = (float) 3.14;
70      }
71  
72      /** redundant 'final' modifier */
73      private final void method() // violation
74      {
75      }
76  }
77  
78  /** Holder for redundant 'final' check. */
79  final class RedundantFinalClass
80  {
81      /** redundant 'final' modifier */
82      public final void finalMethod() // violation
83      {
84      }
85  
86      /** OK */
87      public void method()
88      {
89      }
90  }
91  
92  /** Holder for redundant modifiers of inner implementation */
93  abstract interface InnerImplementation // violation
94  {
95      InnerImplementation inner =
96          new InnerImplementation()
97          {
98              /** compiler requires 'public' modifier */
99              public void method()
100             {
101             }
102         };
103     
104     void method();
105 }
106 
107 /** Holder for redundant modifiers of annotation fields/variables */
108 @interface Annotation
109 {
110     public String s1 = ""; // violation
111     final String s2 = ""; // violation
112     static String s3 = ""; // violation
113     String s4 = "";
114     public String blah(); // violation
115     abstract String blah2(); // violation
116 }
117 
118 @interface MyAnnotation2 {
119 }
120 
121 @interface MyAnnotation4 {
122 }
123 
124 class SafeVarargsUsage {
125     @Deprecated
126     @SafeVarargs
127     private final void foo(int... k) {}
128     
129     @Deprecated
130     @SafeVarargs
131     @SuppressWarnings("")
132     private final void foo1(Object... obj) {}
133 }