< prev index next >

test/java/awt/Container/ContainerAIOOBE/ContainerAIOOBE.java

Print this page
rev 14836 : 8159690: [TESTBUG] Mark headful tests with @key headful.
   1 /*
   2  * Copyright (c) 2014, 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 import java.awt.Button;
  25 import java.awt.Component;
  26 import java.awt.Container;
  27 import java.io.ByteArrayInputStream;
  28 import java.io.ByteArrayOutputStream;
  29 import java.io.ObjectInputStream;
  30 import java.io.ObjectOutputStream;
  31 
  32 /**
  33  * @test

  34  * @bug 8059590
  35  * @summary ArrayIndexOutOfBoundsException occurs when Container with overridden getComponents() is deserialized.
  36  * @author Alexey Ivanov
  37  * @run main ContainerAIOOBE
  38  */
  39 public class ContainerAIOOBE {
  40 
  41     public static void main(final String[] args) throws Exception {
  42         ZContainer z = new ZContainer();
  43         z.add(new Button());
  44 
  45         ByteArrayOutputStream baos = new ByteArrayOutputStream();
  46         ObjectOutputStream oos = new ObjectOutputStream(baos);
  47         oos.writeObject(z);
  48         oos.flush();
  49         oos.close();
  50 
  51         byte[] array = baos.toByteArray();
  52         ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array));
  53 


   1 /*
   2  * Copyright (c) 2014, 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 import java.awt.Button;
  25 import java.awt.Component;
  26 import java.awt.Container;
  27 import java.io.ByteArrayInputStream;
  28 import java.io.ByteArrayOutputStream;
  29 import java.io.ObjectInputStream;
  30 import java.io.ObjectOutputStream;
  31 
  32 /**
  33  * @test
  34  * @key headful
  35  * @bug 8059590
  36  * @summary ArrayIndexOutOfBoundsException occurs when Container with overridden getComponents() is deserialized.
  37  * @author Alexey Ivanov
  38  * @run main ContainerAIOOBE
  39  */
  40 public class ContainerAIOOBE {
  41 
  42     public static void main(final String[] args) throws Exception {
  43         ZContainer z = new ZContainer();
  44         z.add(new Button());
  45 
  46         ByteArrayOutputStream baos = new ByteArrayOutputStream();
  47         ObjectOutputStream oos = new ObjectOutputStream(baos);
  48         oos.writeObject(z);
  49         oos.flush();
  50         oos.close();
  51 
  52         byte[] array = baos.toByteArray();
  53         ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array));
  54 


< prev index next >