Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLDecoder/Test6341798.java
41149 views
1
/*
2
* Copyright (c) 2005, 2011, 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 6341798
27
* @summary Tests name generation for turkish locale
28
* @author Sergey Malenkov
29
*/
30
31
import java.beans.XMLDecoder;
32
import java.io.ByteArrayInputStream;
33
import java.util.Locale;
34
35
import static java.util.Locale.ENGLISH;
36
37
public class Test6341798 {
38
private static final Locale TURKISH = new Locale("tr");
39
40
private static final String DATA
41
= "<java>\n"
42
+ " <object class=\"Test6341798$DataBean\">\n"
43
+ " <void property=\"illegal\">\n"
44
+ " <boolean>true</boolean>\n"
45
+ " </void>\n"
46
+ " </object>\n"
47
+ "</java> ";
48
49
public static void main(String[] args) {
50
Locale reservedLocale = Locale.getDefault();
51
try {
52
test(ENGLISH, DATA.getBytes());
53
test(TURKISH, DATA.getBytes());
54
} finally {
55
// restore the reserved locale
56
Locale.setDefault(reservedLocale);
57
}
58
}
59
60
private static void test(Locale locale, byte[] data) {
61
Locale.setDefault(locale);
62
System.out.println("locale = " + locale);
63
64
XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));
65
System.out.println("object = " + decoder.readObject());
66
decoder.close();
67
}
68
69
public static class DataBean {
70
private boolean illegal;
71
72
public boolean isIllegal() {
73
return this.illegal;
74
}
75
76
public void setIllegal(boolean illegal) {
77
this.illegal = illegal;
78
}
79
80
public String toString() {
81
if (this.illegal) {
82
return "property is set";
83
}
84
throw new Error("property is not set");
85
}
86
}
87
}
88
89