0N/A/*
2362N/A * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/* @test
0N/A * @summary Basic sanity check to test if default (de)serialization is
0N/A * transmitting values properly.
0N/A */
0N/A
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/A
0N/Aclass Item implements Serializable {
0N/A
0N/A static final int ARRAYLEN = 1000;
0N/A static final int STRLEN = 1000;
0N/A static Random rand = new Random(System.currentTimeMillis());
0N/A
0N/A boolean z;
0N/A byte b;
0N/A char c;
0N/A short s;
0N/A int i;
0N/A float f;
0N/A long j;
0N/A double d;
0N/A
0N/A boolean[] zary;
0N/A byte[] bary;
0N/A char[] cary;
0N/A short[] sary;
0N/A int[] iary;
0N/A float[] fary;
0N/A long[] jary;
0N/A double[] dary;
0N/A
0N/A String str;
0N/A Object[] oary;
0N/A
0N/A Item() {
0N/A z = rand.nextBoolean();
0N/A b = (byte) rand.nextInt();
0N/A c = (char) rand.nextInt();
0N/A s = (short) rand.nextInt();
0N/A i = rand.nextInt();
0N/A f = rand.nextFloat();
0N/A j = rand.nextLong();
0N/A d = rand.nextDouble();
0N/A
0N/A zary = new boolean[ARRAYLEN];
0N/A bary = new byte[ARRAYLEN];
0N/A cary = new char[ARRAYLEN];
0N/A sary = new short[ARRAYLEN];
0N/A iary = new int[ARRAYLEN];
0N/A fary = new float[ARRAYLEN];
0N/A jary = new long[ARRAYLEN];
0N/A dary = new double[ARRAYLEN];
0N/A oary = new Object[ARRAYLEN];
0N/A
0N/A for (int i = 0; i < ARRAYLEN; i++) {
0N/A zary[i] = rand.nextBoolean();
0N/A bary[i] = (byte) rand.nextInt();
0N/A cary[i] = (char) rand.nextInt();
0N/A sary[i] = (short) rand.nextInt();
0N/A iary[i] = rand.nextInt();
0N/A fary[i] = rand.nextFloat();
0N/A jary[i] = rand.nextLong();
0N/A dary[i] = rand.nextDouble();
0N/A oary[i] = new Integer(rand.nextInt());
0N/A }
0N/A
0N/A char[] strChars = new char[STRLEN];
0N/A for (int i = 0; i < STRLEN; i++) {
0N/A strChars[i] = (char) rand.nextInt();
0N/A }
0N/A str = new String(strChars);
0N/A }
0N/A
0N/A public boolean equals(Object obj) {
0N/A if (!(obj instanceof Item)) {
0N/A return false;
0N/A }
0N/A Item other = (Item) obj;
0N/A
0N/A if ((z != other.z) || (b != other.b) || (c != other.c) ||
0N/A (s != other.s) || (i != other.i) || (f != other.f) ||
0N/A (j != other.j) || (d != other.d))
0N/A {
0N/A return false;
0N/A }
0N/A
0N/A for (int i = 0; i < ARRAYLEN; i++) {
0N/A if ((zary[i] != other.zary[i]) || (bary[i] != other.bary[i]) ||
0N/A (cary[i] != other.cary[i]) || (sary[i] != other.sary[i]) ||
0N/A (iary[i] != other.iary[i]) || (fary[i] != other.fary[i]) ||
0N/A (jary[i] != other.jary[i]) || (dary[i] != other.dary[i]) ||
0N/A !oary[i].equals(other.oary[i]))
0N/A {
0N/A return false;
0N/A }
0N/A }
0N/A
0N/A if (!str.equals(other.str)) {
0N/A return false;
0N/A }
0N/A
0N/A return true;
0N/A }
0N/A}
0N/A
0N/Apublic class SanityCheck {
0N/A public static void main(String[] args) throws Exception {
0N/A for (int i = 0; i < 20; i++) {
0N/A ByteArrayOutputStream bout = new ByteArrayOutputStream();
0N/A ObjectOutputStream oout = new ObjectOutputStream(bout);
0N/A Item item = new Item();
0N/A oout.writeObject(item);
0N/A oout.close();
0N/A
0N/A ObjectInputStream oin = new ObjectInputStream(
0N/A new ByteArrayInputStream(bout.toByteArray()));
0N/A Item itemcopy = (Item) oin.readObject();
0N/A
0N/A if (! item.equals(itemcopy)) {
0N/A throw new Error();
0N/A }
0N/A }
0N/A }
0N/A}