Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/management/Introspector/LegacyConstructorPropertiesTest.java
41149 views
1
2
/*
3
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*/
24
25
import java.beans.ConstructorProperties;
26
import javax.management.ConstructorParameters;
27
import javax.management.MBeanServer;
28
import javax.management.MBeanServerFactory;
29
import javax.management.ObjectName;
30
31
/*
32
* @test
33
* @bug 7199353
34
* @summary Asserts that 'java.beans.ConstructorProperties' annotation is still
35
* recognized and properly handled for custom types mapped to open types.
36
* Also, makes sure that if the same constructor is annotated by both
37
* j.b.ConstructorProperties and j.m.ConstructorProperties annotations
38
* only j.m.ConstructorProperties annotation is considered.
39
* @author Jaroslav Bachorik
40
*
41
* @modules java.desktop
42
* java.management
43
*
44
* @run main LegacyConstructorPropertiesTest
45
*/
46
47
public class LegacyConstructorPropertiesTest {
48
public static class CustomType {
49
private String name;
50
private int value;
51
@ConstructorProperties({"name", "value"})
52
public CustomType(String name, int value) {
53
this.name = name;
54
this.value = value;
55
}
56
57
// if @java.beans.ConstructorProperties would be used
58
// the introspector would choke on this
59
@ConstructorProperties("noname")
60
@ConstructorParameters("name")
61
public CustomType(String name) {
62
this.name = name;
63
this.value = -1;
64
}
65
66
public String getName() {
67
return name;
68
}
69
70
public void setName(String name) {
71
this.name = name;
72
}
73
74
public int getValue() {
75
return value;
76
}
77
78
public void setValue(int value) {
79
this.value = value;
80
}
81
}
82
83
public static interface CustomMXBean {
84
public CustomType getProp();
85
public void setProp(CustomType prop);
86
}
87
88
public static final class Custom implements CustomMXBean {
89
private CustomType prop;
90
91
@Override
92
public CustomType getProp() {
93
return prop;
94
}
95
96
@Override
97
public void setProp(CustomType prop) {
98
this.prop = prop;
99
}
100
}
101
102
public static void main(String[] args) throws Exception {
103
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
104
CustomMXBean mbean = new Custom();
105
106
mbs.registerMBean(mbean, ObjectName.getInstance("test:type=Custom"));
107
}
108
}
109
110