Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLEncoder/Test6921644.java
41149 views
1
/*
2
* Copyright (c) 2010, 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 6921644
27
* @summary Tests references to cached integer
28
* @run main/othervm -Djava.security.manager=allow Test6921644
29
* @author Sergey Malenkov
30
*/
31
32
import java.beans.ConstructorProperties;
33
import java.util.ArrayList;
34
import java.util.List;
35
36
public final class Test6921644 extends AbstractTest {
37
public static void main(String[] args) {
38
new Test6921644().test(true);
39
}
40
41
protected Object getObject() {
42
Owner<Author> o = new Owner<Author>(100); // it works if ID >= 128
43
44
Category c = new Category(o);
45
46
Document d1 = new Document(o);
47
Document d2 = new Document(o);
48
Document d3 = new Document(o);
49
50
Author a1 = new Author(o);
51
Author a2 = new Author(o);
52
Author a3 = new Author(o);
53
54
o.getList().add(a1);
55
o.getList().add(a2);
56
o.getList().add(a3);
57
58
a3.setRef(o.getId());
59
60
d2.setCategory(c);
61
d3.setCategory(c);
62
63
a1.addDocument(d1);
64
a1.addDocument(d2);
65
a3.addDocument(d3);
66
67
c.addDocument(d2);
68
c.addDocument(d3);
69
70
return o;
71
}
72
73
public static class Owner<T> {
74
private int id;
75
private List<T> list = new ArrayList<T>();
76
77
@ConstructorProperties("id")
78
public Owner(int id) {
79
this.id = id;
80
}
81
82
public int getId() {
83
return this.id;
84
}
85
86
public List<T> getList() {
87
return this.list;
88
}
89
90
public void setList(List<T> list) {
91
this.list = list;
92
}
93
}
94
95
public static class Author {
96
private int id;
97
private int ref;
98
private Owner owner;
99
private List<Document> list = new ArrayList<Document>();
100
101
@ConstructorProperties("owner")
102
public Author(Owner<Author> owner) {
103
this.owner = owner;
104
this.id = owner.getId();
105
}
106
107
public Owner getOwner() {
108
return this.owner;
109
}
110
111
public Integer getId() {
112
return this.id;
113
}
114
115
public void setId(Integer id) {
116
this.id = id;
117
}
118
119
public Integer getRef() {
120
return this.ref;
121
}
122
123
public void setRef(Integer ref) {
124
this.ref = ref;
125
}
126
127
public List<Document> getList() {
128
return this.list;
129
}
130
131
public void setList(List<Document> list) {
132
this.list = list;
133
}
134
135
public void addDocument(Document document) {
136
this.list.add(document);
137
document.setAuthor(this);
138
}
139
}
140
141
public static class Category {
142
private Owner owner;
143
private List<Document> list = new ArrayList<Document>();
144
145
@ConstructorProperties("owner")
146
public Category(Owner owner) {
147
this.owner = owner;
148
}
149
150
public Owner getOwner() {
151
return this.owner;
152
}
153
154
public List<Document> getList() {
155
return this.list;
156
}
157
158
public void setList(List<Document> list) {
159
this.list = list;
160
}
161
162
public void addDocument(Document document) {
163
this.list.add(document);
164
document.setCategory(this);
165
}
166
}
167
168
public static class Document {
169
private Owner owner;
170
private Author author;
171
private Category category;
172
173
@ConstructorProperties("owner")
174
public Document(Owner owner) {
175
this.owner = owner;
176
}
177
178
public Owner getOwner() {
179
return this.owner;
180
}
181
182
public Author getAuthor() {
183
return this.author;
184
}
185
186
public void setAuthor(Author author) {
187
this.author = author;
188
}
189
190
public Category getCategory() {
191
return this.category;
192
}
193
194
public void setCategory(Category category) {
195
this.category = category;
196
}
197
}
198
}
199
200