Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/text/Format/NumberFormat/SerializationLoadTest.java
41152 views
1
/*
2
* Copyright (c) 1998, 2016, 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 4101150
27
* @library /java/text/testlib
28
* @build SerializationLoadTest HexDumpReader
29
* @run main SerializationLoadTest
30
* @summary test serialization compatibility of DecimalFormat and DecimalFormatSymbols
31
* @key randomness
32
*/
33
34
import java.io.InputStream;
35
import java.io.ObjectInputStream;
36
import java.io.Serializable;
37
import java.text.DecimalFormat;
38
import java.text.DecimalFormatSymbols;
39
import java.text.NumberFormat;
40
import java.util.Random;
41
42
public class SerializationLoadTest {
43
44
public static void main(String[] args)
45
{
46
try {
47
InputStream istream1 = HexDumpReader.getStreamFromHexDump("DecimalFormat.114.txt");
48
ObjectInputStream p = new ObjectInputStream(istream1);
49
CheckDecimalFormat it = (CheckDecimalFormat)p.readObject();
50
System.out.println("1.1.4 DecimalFormat Loaded ok.");
51
System.out.println(it.Update());
52
System.out.println("Called Update successfully.");
53
istream1.close();
54
55
InputStream istream2 = HexDumpReader.getStreamFromHexDump("DecimalFormatSymbols.114.txt");
56
ObjectInputStream p2 = new ObjectInputStream(istream2);
57
CheckDecimalFormatSymbols it2 = (CheckDecimalFormatSymbols)p2.readObject();
58
System.out.println("1.1.4 DecimalFormatSymbols Loaded ok.");
59
System.out.println("getDigit : " + it2.Update());
60
System.out.println("Called Update successfully.");
61
istream2.close();
62
} catch (Exception e) {
63
e.printStackTrace();
64
}
65
}
66
}
67
68
@SuppressWarnings("serial")
69
class CheckDecimalFormat implements Serializable
70
{
71
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
72
73
public String Update()
74
{
75
Random r = new Random();
76
return _decFormat.format(r.nextDouble());
77
}
78
}
79
80
@SuppressWarnings("serial")
81
class CheckDecimalFormatSymbols implements Serializable
82
{
83
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();
84
85
public char Update()
86
{
87
return _decFormatSymbols.getDigit();
88
}
89
}
90
91