Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/Introspector/Test6723447.java
41149 views
1
/*
2
* Copyright (c) 2009, 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
/*
25
* @test
26
* @bug 6723447
27
* @summary Tests return type for property setters
28
* @author Sergey Malenkov
29
*/
30
31
import java.beans.IndexedPropertyDescriptor;
32
import java.beans.IntrospectionException;
33
import java.beans.Introspector;
34
import java.beans.PropertyDescriptor;
35
import java.lang.reflect.Method;
36
import java.math.BigDecimal;
37
38
public class Test6723447 {
39
40
public static void main(String[] args) {
41
test(Test6723447.class);
42
test(BigDecimal.class);
43
}
44
45
private static void test(Class<?> type) {
46
for (PropertyDescriptor pd : getPropertyDescriptors(type)) {
47
test(pd.getWriteMethod());
48
if (pd instanceof IndexedPropertyDescriptor) {
49
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
50
test(ipd.getIndexedWriteMethod());
51
}
52
}
53
}
54
55
private static void test(Method method) {
56
if (method != null) {
57
Class<?> type = method.getReturnType();
58
if (!type.equals(void.class)) {
59
throw new Error("unexpected return type: " + type);
60
}
61
}
62
}
63
64
private static PropertyDescriptor[] getPropertyDescriptors(Class<?> type) {
65
try {
66
return Introspector.getBeanInfo(type).getPropertyDescriptors();
67
}
68
catch (IntrospectionException exception) {
69
throw new Error("unexpected exception", exception);
70
}
71
}
72
73
public Object getValue() {
74
return null;
75
}
76
77
public Object setValue(Object value) {
78
return value;
79
}
80
81
public Object getValues(int index) {
82
return null;
83
}
84
85
public Object setValues(int index, Object value) {
86
return value;
87
}
88
}
89
90