test/jdk/java/io/Serializable/fieldTypeString/Write.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    40 
    40 
    41 import java.io.*;
    41 import java.io.*;
    42 
    42 
    43 class Foo implements Serializable {
    43 class Foo implements Serializable {
    44     private static final long serialVersionUID = 0L;
    44     private static final long serialVersionUID = 0L;
       
    45     @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    45     Object obj;
    46     Object obj;
    46 
    47 
    47     Foo(Object obj) {
    48     Foo(Object obj) {
    48         this.obj = obj;
    49         this.obj = obj;
    49     }
    50     }
    57 public class Write {
    58 public class Write {
    58     public static void main(String[] args) throws Exception {
    59     public static void main(String[] args) throws Exception {
    59         ObjectOutputStream oout =
    60         ObjectOutputStream oout =
    60             new ObjectOutputStream(new FileOutputStream("foo.ser"));
    61             new ObjectOutputStream(new FileOutputStream("foo.ser"));
    61         oout.writeObject(new Foo("foo"));
    62         oout.writeObject(new Foo("foo"));
    62         oout.writeObject(new Foo(new Integer(0)));
    63         oout.writeObject(new Foo(0));
    63         oout.close();
    64         oout.close();
    64 
    65 
    65         oout = new ObjectOutputStream(new FileOutputStream("bar.ser"));
    66         oout = new ObjectOutputStream(new FileOutputStream("bar.ser"));
    66         oout.writeObject(new Bar());
    67         oout.writeObject(new Bar());
    67         oout.close();
    68         oout.close();