author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 18757 | jdk/test/java/beans/Introspector/Test6707231.java@5ab9e48648e5 |
permissions | -rw-r--r-- |
18757
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
1 |
/* |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
4 |
* |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
8 |
* |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
14 |
* |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
18 |
* |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
21 |
* questions. |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
22 |
*/ |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
23 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
24 |
import java.beans.PropertyDescriptor; |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
25 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
26 |
/* |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
27 |
* @test |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
28 |
* @bug 6707231 |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
29 |
* @summary Tests the boolean getter |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
30 |
* @author Sergey Malenkov |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
31 |
*/ |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
32 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
33 |
public class Test6707231 { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
34 |
public static void main(String[] args) throws Exception { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
35 |
test(Bean.class, Bean.class); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
36 |
test(Public.class, Public.class); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
37 |
test(Private.class, Bean.class); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
38 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
39 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
40 |
public static class Bean { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
41 |
private boolean value; |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
42 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
43 |
public boolean isValue() { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
44 |
return this.value; |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
45 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
46 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
47 |
public void setValue(boolean value) { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
48 |
this.value = value; |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
49 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
50 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
51 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
52 |
public static class Public extends Bean { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
53 |
public boolean isValue() { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
54 |
return super.isValue(); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
55 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
56 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
57 |
public void setValue(boolean value) { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
58 |
super.setValue(value); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
59 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
60 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
61 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
62 |
private static class Private extends Bean { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
63 |
public boolean isValue() { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
64 |
return super.isValue(); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
65 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
66 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
67 |
public void setValue(boolean value) { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
68 |
super.setValue(value); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
69 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
70 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
71 |
|
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
72 |
private static void test(Class<?> actual, Class<?> expected) { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
73 |
PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(actual, "value"); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
74 |
Class<?> getter = pd.getReadMethod().getDeclaringClass(); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
75 |
Class<?> setter = pd.getWriteMethod().getDeclaringClass(); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
76 |
if ((getter != expected) || (setter != expected)) { |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
77 |
throw new Error(actual.getName()); |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
78 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
79 |
} |
5ab9e48648e5
6707231: Wrong read Method returned for boolen properties
malenkov
parents:
diff
changeset
|
80 |
} |