View Javadoc
1   /*
2   EmptyBlock
3   option = invalid_option
4   tokens = (default)LITERAL_WHILE, LITERAL_TRY, LITERAL_FINALLY, LITERAL_DO, \
5            LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, INSTANCE_INIT, STATIC_INIT, \
6            LITERAL_SWITCH, LITERAL_SYNCHRONIZED
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.blocks.emptyblock;
12  
13  import java.io.*; // star import for instantiation tests
14  import java.awt.Dimension; // explicit import for instantiation tests
15  import java.awt.Color;
16  
17  /**
18   * Test case for detecting empty block statements.
19   **/
20  class InputEmptyBlockSemanticInvalid
21  {
22      static {
23          Boolean x = new Boolean(true);
24      }
25  
26      {
27          Boolean x = new Boolean(true);
28          Boolean[] y = new Boolean[]{Boolean.TRUE, Boolean.FALSE};
29      }
30  
31      Boolean getBoolean()
32      {
33          return new java.lang.Boolean(true);
34      }
35  
36      void exHandlerTest()
37      {
38          try {
39          }
40          finally {
41          }
42          try {
43              // something
44          }
45          finally {
46              // something
47          }
48          try {
49              ; // something
50          }
51          finally {
52              ; // statement
53          }
54      }
55  
56      /** test **/
57      private static final long IGNORE = 666l + 666L;
58  
59      public class EqualsVsHashCode1
60      {
61          public boolean equals(int a)
62          {
63              return a == 1;
64          }
65      }
66  
67      // empty instance initializer
68      {
69      }
70  
71      private class InputBraces {
72  
73      }
74  
75      synchronized void foo() {
76          synchronized (this) {}
77          synchronized (Class.class) {
78              synchronized (new Object()) {
79                  // text
80              }
81          }
82      }
83  
84  
85      static {
86  
87          int a = 0;}
88  
89      static {
90  
91      }
92  }