Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/text/Format/NumberFormat/SerializationLoadTest.java
47178 views
/*1* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 410115026* @library /java/text/testlib27* @build SerializationLoadTest HexDumpReader28* @run main SerializationLoadTest29* @summary test serialization compatibility of DecimalFormat and DecimalFormatSymbols30* @key randomness31*/3233import java.awt.*;34import java.text.*;35import java.util.*;36import java.io.*;3738public class SerializationLoadTest {3940public static void main(String[] args)41{42try {43InputStream istream1 = HexDumpReader.getStreamFromHexDump("DecimalFormat.114.txt");44ObjectInputStream p = new ObjectInputStream(istream1);45CheckDecimalFormat it = (CheckDecimalFormat)p.readObject();46System.out.println("1.1.4 DecimalFormat Loaded ok.");47System.out.println(it.Update());48System.out.println("Called Update successfully.");49istream1.close();5051InputStream istream2 = HexDumpReader.getStreamFromHexDump("DecimalFormatSymbols.114.txt");52ObjectInputStream p2 = new ObjectInputStream(istream2);53CheckDecimalFormatSymbols it2 = (CheckDecimalFormatSymbols)p2.readObject();54System.out.println("1.1.4 DecimalFormatSymbols Loaded ok.");55System.out.println("getDigit : " + it2.Update());56System.out.println("Called Update successfully.");57istream2.close();58} catch (Exception e) {59e.printStackTrace();60}61}62}6364class CheckDecimalFormat implements Serializable65{66DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();6768public String Update()69{70Random r = new Random();71return _decFormat.format(r.nextDouble());72}73}7475class CheckDecimalFormatSymbols implements Serializable76{77DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();7879public char Update()80{81return _decFormatSymbols.getDigit();82}83}848586