Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/beans/Introspector/Test8040656.java
47964 views
1
/*
2
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.beans.Introspector;
25
import java.beans.MethodDescriptor;
26
27
/*
28
* @test
29
* @bug 8040656
30
* @summary Tests that a normal method is preferred to a synthetic one
31
* @author Sergey Malenkov
32
*/
33
34
public class Test8040656 {
35
public static void main(String[] args) throws Exception {
36
test(String.class, C.class);
37
test(String.class, C1.class);
38
test(String.class, C2.class);
39
test(String.class, C3.class);
40
test(String.class, C4.class);
41
test(String.class, C5.class);
42
test(String.class, C6.class);
43
test(String.class, C7.class);
44
test(String.class, C8.class);
45
test(String.class, C9.class);
46
}
47
48
private static void test(Class<?> type, Class<?> bean) throws Exception {
49
for (MethodDescriptor md : Introspector.getBeanInfo(bean).getMethodDescriptors()) {
50
if (md.getName().equals("getFoo")) {
51
if (type != md.getMethod().getReturnType()) {
52
throw new Error("unexpected type");
53
}
54
}
55
}
56
}
57
58
public interface A {
59
public Object getFoo();
60
}
61
62
public class C implements A {
63
@Override
64
public String getFoo() {
65
return null;
66
}
67
}
68
69
public class C1 implements A {
70
@Override
71
public String getFoo() {
72
return null;
73
}
74
75
public String getFoo1() {
76
return null;
77
}
78
}
79
80
public class C2 implements A {
81
@Override
82
public String getFoo() {
83
return null;
84
}
85
86
public String getFoo1() {
87
return null;
88
}
89
90
public String getFoo2() {
91
return null;
92
}
93
}
94
95
public class C3 implements A {
96
@Override
97
public String getFoo() {
98
return null;
99
}
100
101
public String getFoo1() {
102
return null;
103
}
104
105
public String getFoo2() {
106
return null;
107
}
108
109
public String getFoo3() {
110
return null;
111
}
112
}
113
114
public class C4 implements A {
115
@Override
116
public String getFoo() {
117
return null;
118
}
119
120
public String getFoo1() {
121
return null;
122
}
123
124
public String getFoo2() {
125
return null;
126
}
127
128
public String getFoo3() {
129
return null;
130
}
131
132
public String getFoo4() {
133
return null;
134
}
135
}
136
137
public class C5 implements A {
138
@Override
139
public String getFoo() {
140
return null;
141
}
142
143
public String getFoo1() {
144
return null;
145
}
146
147
public String getFoo2() {
148
return null;
149
}
150
151
public String getFoo3() {
152
return null;
153
}
154
155
public String getFoo4() {
156
return null;
157
}
158
159
public String getFoo5() {
160
return null;
161
}
162
}
163
164
public class C6 implements A {
165
@Override
166
public String getFoo() {
167
return null;
168
}
169
170
public String getFoo1() {
171
return null;
172
}
173
174
public String getFoo2() {
175
return null;
176
}
177
178
public String getFoo3() {
179
return null;
180
}
181
182
public String getFoo4() {
183
return null;
184
}
185
186
public String getFoo5() {
187
return null;
188
}
189
190
public String getFoo6() {
191
return null;
192
}
193
}
194
195
public class C7 implements A {
196
@Override
197
public String getFoo() {
198
return null;
199
}
200
201
public String getFoo1() {
202
return null;
203
}
204
205
public String getFoo2() {
206
return null;
207
}
208
209
public String getFoo3() {
210
return null;
211
}
212
213
public String getFoo4() {
214
return null;
215
}
216
217
public String getFoo5() {
218
return null;
219
}
220
221
public String getFoo6() {
222
return null;
223
}
224
225
public String getFoo7() {
226
return null;
227
}
228
}
229
230
public class C8 implements A {
231
@Override
232
public String getFoo() {
233
return null;
234
}
235
236
public String getFoo1() {
237
return null;
238
}
239
240
public String getFoo2() {
241
return null;
242
}
243
244
public String getFoo3() {
245
return null;
246
}
247
248
public String getFoo4() {
249
return null;
250
}
251
252
public String getFoo5() {
253
return null;
254
}
255
256
public String getFoo6() {
257
return null;
258
}
259
260
public String getFoo7() {
261
return null;
262
}
263
264
public String getFoo8() {
265
return null;
266
}
267
}
268
269
public class C9 implements A {
270
@Override
271
public String getFoo() {
272
return null;
273
}
274
275
public String getFoo1() {
276
return null;
277
}
278
279
public String getFoo2() {
280
return null;
281
}
282
283
public String getFoo3() {
284
return null;
285
}
286
287
public String getFoo4() {
288
return null;
289
}
290
291
public String getFoo5() {
292
return null;
293
}
294
295
public String getFoo6() {
296
return null;
297
}
298
299
public String getFoo7() {
300
return null;
301
}
302
303
public String getFoo8() {
304
return null;
305
}
306
307
public String getFoo9() {
308
return null;
309
}
310
}
311
}
312
313