Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/Introspector/Test4168833.java
41149 views
1
/*
2
* Copyright (c) 2003, 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
/*
25
* @test
26
* @bug 4168833 8034085
27
* @summary Tests that Introspector does not create IndexedPropertyDescriptor
28
* from non-indexed PropertyDescriptor
29
* @author Mark Davidson
30
* @author Sergey Malenkov
31
*/
32
33
import java.awt.Color;
34
import java.awt.Dimension;
35
36
import java.beans.IndexedPropertyDescriptor;
37
import java.beans.PropertyDescriptor;
38
39
/**
40
* The base class "color" property
41
* creates both an IndexedPropertyDescriptor which has a conflicting
42
* type for getColor.
43
*/
44
public class Test4168833 {
45
public static void main(String[] args) throws Exception {
46
// When the Sub class is introspected,
47
// the property type should be color.
48
// The complete "classic" set of properties
49
// has been completed accross the hierarchy.
50
test(Sub.class);
51
test(Sub2.class);
52
}
53
54
private static void test(Class type) {
55
PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(type, "prop");
56
if (pd instanceof IndexedPropertyDescriptor) {
57
error(pd, type.getSimpleName() + ".prop should not be an indexed property");
58
}
59
if (!pd.getPropertyType().equals(Color.class)) {
60
error(pd, type.getSimpleName() + ".prop type should be a Color");
61
}
62
if (null == pd.getReadMethod()) {
63
error(pd, type.getSimpleName() + ".prop should have classic read method");
64
}
65
if (null == pd.getWriteMethod()) {
66
error(pd, type.getSimpleName() + ".prop should have classic write method");
67
}
68
}
69
70
private static void error(PropertyDescriptor pd, String message) {
71
BeanUtils.reportPropertyDescriptor(pd);
72
throw new Error(message);
73
}
74
75
public static class Base {
76
public Color getProp() {
77
return null;
78
}
79
80
public Dimension getProp(int i) {
81
return null;
82
}
83
}
84
85
public static class Sub extends Base {
86
public void setProp(Color c) {
87
}
88
}
89
90
public static class Base2 {
91
public void setProp(Color c) {
92
}
93
94
public void setProp(int i, Dimension d) {
95
}
96
}
97
98
public static class Sub2 extends Base2 {
99
public Color getProp() {
100
return null;
101
}
102
}
103
}
104
105