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