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.awt.*; 35 import java.text.*; 36 import java.util.*; 37 import java.io.*; 38 39 public class SerializationLoadTest { 40 41 public static void main(String[] args) 42 { 43 try { 44 InputStream istream1 = HexDumpReader.getStreamFromHexDump("DecimalFormat.114.txt"); 45 ObjectInputStream p = new ObjectInputStream(istream1); 46 CheckDecimalFormat it = (CheckDecimalFormat)p.readObject(); 47 System.out.println("1.1.4 DecimalFormat Loaded ok."); 48 System.out.println(it.Update()); 49 System.out.println("Called Update successfully."); 50 istream1.close(); 51 52 InputStream istream2 = HexDumpReader.getStreamFromHexDump("DecimalFormatSymbols.114.txt"); 53 ObjectInputStream p2 = new ObjectInputStream(istream2); 54 CheckDecimalFormatSymbols it2 = (CheckDecimalFormatSymbols)p2.readObject(); 55 System.out.println("1.1.4 DecimalFormatSymbols Loaded ok."); 56 System.out.println("getDigit : " + it2.Update()); 57 System.out.println("Called Update successfully."); 58 istream2.close(); 59 } catch (Exception e) { 60 e.printStackTrace(); 61 } 62 } 63 } 64 65 @SuppressWarnings("serial") 66 class CheckDecimalFormat implements Serializable 67 { 68 DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance(); 69 70 public String Update() 71 { 72 Random r = new Random(); 73 return _decFormat.format(r.nextDouble()); 74 } 75 } 76 77 @SuppressWarnings("serial") 78 class CheckDecimalFormatSymbols implements Serializable 79 { 80 DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols(); 81 82 public char Update() 83 { 84 return _decFormatSymbols.getDigit(); 85 } 86 }