1
2
3
4
5
6
7
8
9 package com.puppycrawl.tools.checkstyle.checks.coding.illegalinstantiation;
10
11 import java.io.*;
12 import java.awt.Dimension;
13 import java.awt.Color;
14
15
16
17
18
19 class InputIllegalInstantiationSemantic
20 {
21
22 static {
23 Boolean x = new Boolean(true);
24 }
25
26
27 {
28 Boolean x = new Boolean(true);
29 Boolean[] y = new Boolean[]{Boolean.TRUE, Boolean.FALSE};
30 }
31
32
33 Boolean getBoolean()
34 {
35 return new java.lang.Boolean(true);
36 }
37
38 void otherInstantiations()
39 {
40
41 Object o1 = new InputBraces();
42 Object o2 = new InputModifier();
43
44 ByteArrayOutputStream s = new ByteArrayOutputStream();
45 File f = new File("/tmp");
46
47 Dimension dim = new Dimension();
48 Color col = new Color(0, 0, 0);
49 }
50
51 public class EqualsVsHashCode1
52 {
53 public boolean equals(int a)
54 {
55 return a == 1;
56 }
57 }
58
59 public class EqualsVsHashCode2
60 {
61 public boolean equals(String a)
62 {
63 return true;
64 }
65 }
66
67 public class EqualsVsHashCode3
68 {
69 public boolean equals(Object a)
70 {
71 return true;
72 }
73
74 public int hashCode()
75 {
76 return 0;
77 }
78 }
79
80 public class EqualsVsHashCode4
81 {
82
83 ByteArrayOutputStream bos1 = new ByteArrayOutputStream()
84 {
85 public boolean equals(Object a)
86 {
87 return true;
88 }
89
90 public int hashCode()
91 {
92 return 0;
93 }
94 };
95
96 ByteArrayOutputStream bos2 = new ByteArrayOutputStream()
97 {
98 public boolean equals(Object a)
99 {
100 return true;
101 }
102 };
103 }
104
105 public void triggerEmptyBlockWithoutBlock()
106 {
107
108 if (true)
109 return;
110 }
111
112
113 {
114 }
115
116 public class EqualsVsHashCode5
117 {
118 public <A> boolean equals(int a)
119 {
120 return a == 1;
121 }
122 }
123
124 public class EqualsVsHashCode6
125 {
126 public <A> boolean equals(Comparable<A> a)
127 {
128 return true;
129 }
130 }
131
132 private class InputBraces {
133
134 }
135
136 private class InputModifier {
137
138 }
139 }