1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.upperell;
8
9 import java.awt.*;
10 import java.io.ByteArrayOutputStream;
11 import java.io.File;
12
13
14
15
16
17 class InputUpperEllSemantic
18 {
19
20 static {
21 Boolean x = new Boolean(true);
22 }
23
24
25 {
26 Boolean x = new Boolean(true);
27 Boolean[] y = new Boolean[]{Boolean.TRUE, Boolean.FALSE};
28 }
29
30
31 Boolean getBoolean()
32 {
33 return new Boolean(true);
34 }
35
36 void otherInstantiations()
37 {
38
39 Object o1 = new InputBraces();
40 Object o2 = new InputModifier();
41
42 ByteArrayOutputStream s = new ByteArrayOutputStream();
43 File f = new File("/tmp");
44
45 Dimension dim = new Dimension();
46 Color col = new Color(0, 0, 0);
47 }
48
49 void exHandlerTest()
50 {
51 try {
52 ;
53 }
54 catch (IllegalStateException emptyCatchIsAlwaysAnError) {
55 }
56 catch (NullPointerException ex) {
57
58
59 }
60 catch (ArrayIndexOutOfBoundsException ex) {
61 ;
62
63
64 }
65 catch (NegativeArraySizeException ex) {
66 {
67 }
68
69 }
70 catch (UnsupportedOperationException handledException) {
71 System.identityHashCode(handledException.getMessage());
72 }
73 catch (SecurityException ex) { }
74 catch (StringIndexOutOfBoundsException ex) {}
75 catch (IllegalArgumentException ex) { }
76
77 try {
78 }
79 finally {
80 }
81 try {
82
83 }
84 finally {
85
86 }
87 try {
88 ;
89 }
90 finally {
91 ;
92 }
93 }
94
95
96 private static final long IGNORE = 666l + 666L;
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 public class EqualsVsHashCode1
119 {
120 public boolean equals(int a)
121 {
122 return a == 1;
123 }
124 }
125
126 public class EqualsVsHashCode2
127 {
128 public boolean equals(String a)
129 {
130 return true;
131 }
132 }
133
134 public class EqualsVsHashCode3
135 {
136 public boolean equals(Object a)
137 {
138 return true;
139 }
140
141 public int hashCode()
142 {
143 return 0;
144 }
145 }
146
147 public class EqualsVsHashCode4
148 {
149
150 ByteArrayOutputStream bos1 = new ByteArrayOutputStream()
151 {
152 public boolean equals(Object a)
153 {
154 return true;
155 }
156
157 public int hashCode()
158 {
159 return 0;
160 }
161 };
162
163 ByteArrayOutputStream bos2 = new ByteArrayOutputStream()
164 {
165 public boolean equals(Object a)
166 {
167 return true;
168 }
169 };
170 }
171
172 public void triggerEmptyBlockWithoutBlock()
173 {
174
175 if (true)
176 return;
177 }
178
179
180 {
181 }
182
183 public class EqualsVsHashCode5
184 {
185 public <A> boolean equals(int a)
186 {
187 return a == 1;
188 }
189 }
190
191 public class EqualsVsHashCode6
192 {
193 public <A> boolean equals(Comparable<A> a)
194 {
195 return true;
196 }
197 }
198
199 private class InputBraces {
200
201 }
202
203 private class InputModifier {
204
205 }
206
207 synchronized void foo() {
208 synchronized (this) {}
209 synchronized (Class.class) {
210 synchronized (new Object()) {
211
212 }
213 }
214 }
215
216
217 static {
218
219 int a = 0;}
220
221 static {
222
223 }
224 }