4189N/A/*
4189N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4189N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4189N/A *
4189N/A * This code is free software; you can redistribute it and/or modify it
4189N/A * under the terms of the GNU General Public License version 2 only, as
4189N/A * published by the Free Software Foundation.
4189N/A *
4189N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4189N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4189N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4189N/A * version 2 for more details (a copy is included in the LICENSE file that
4189N/A * accompanied this code).
4189N/A *
4189N/A * You should have received a copy of the GNU General Public License version
4189N/A * 2 along with this work; if not, write to the Free Software Foundation,
4189N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4189N/A *
4189N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4189N/A * or visit www.oracle.com if you need additional information or have any
4189N/A * questions.
4189N/A */
4189N/A
4189N/A/**
4189N/A * @test
4189N/A * @bug 7040717 6522514
4189N/A * @summary Verifies that subclasses of Arc2D can be serialized.
4189N/A * @run main SerializationTest
4189N/A */
4189N/A
4189N/Aimport java.awt.geom.Rectangle2D;
4189N/Aimport java.awt.geom.Arc2D;
4189N/Aimport java.io.Serializable;
4189N/Aimport java.io.File;
4189N/Aimport java.io.FileInputStream;
4189N/Aimport java.io.FileOutputStream;
4189N/Aimport java.io.ObjectInputStream;
4189N/Aimport java.io.ObjectOutputStream;
4189N/A
4189N/Apublic class SerializationTest {
4189N/A static boolean failed;
4189N/A public static void main(String args[]) {
4189N/A test(new Arc());
4189N/A test(new ArcF());
4189N/A test(new ArcD());
4189N/A if (failed) throw new RuntimeException("some tests failed");
4189N/A }
4189N/A
4189N/A public static void test(Object a) {
4189N/A try {
4189N/A File objectbin = new File("object.bin");
4189N/A FileOutputStream fos = new FileOutputStream(objectbin);
4189N/A ObjectOutputStream out = new ObjectOutputStream(fos);
4189N/A out.writeObject(a);
4189N/A fos.close();
4189N/A FileInputStream fis = new FileInputStream(objectbin);
4189N/A ObjectInputStream in = new ObjectInputStream(fis);
4189N/A Object o = in.readObject();
4189N/A fis.close();
4189N/A System.err.println(o);
4189N/A } catch (Throwable ex) {
4189N/A ex.printStackTrace();
4189N/A failed = true;
4189N/A }
4189N/A }
4189N/A
4189N/A static class Arc extends Arc2D implements Serializable {
4189N/A public Arc() {
4189N/A super(Arc2D.OPEN);
4189N/A }
4189N/A
4189N/A public Rectangle2D makeBounds(double x, double y, double w, double h) {
4189N/A return new Rectangle2D.Double(x, y, w, h);
4189N/A }
4189N/A public double getX() { return 0; }
4189N/A public double getY() { return 0; }
4189N/A public double getWidth() { return 0; }
4189N/A public double getHeight() { return 0; }
4189N/A public double getAngleExtent() { return 0; }
4189N/A public double getAngleStart() { return 0; }
4189N/A public void setAngleExtent(double angExt) { }
4189N/A public void setAngleStart(double angExt) { }
4189N/A public void setFrame(double x, double y, double w, double h) {}
4189N/A public void setArc(double x, double y, double w, double h,
4189N/A double s, double e, int c)
4189N/A {
4189N/A }
4189N/A public boolean isEmpty() { return false; };
4189N/A }
4189N/A
4189N/A static class ArcF extends Arc2D.Float implements Serializable {
4189N/A public ArcF() {
4189N/A }
4189N/A }
4189N/A
4189N/A static class ArcD extends Arc2D.Double implements Serializable {
4189N/A public ArcD() {
4189N/A }
4189N/A }
4189N/A}