test/jdk/java/io/Serializable/enum/ignoreSerializationMethods/Test.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 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.
    31 
    31 
    32 enum Foo {
    32 enum Foo {
    33 
    33 
    34     foo,
    34     foo,
    35     bar {
    35     bar {
       
    36         @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    36         private void writeObject(ObjectOutputStream out) throws IOException {
    37         private void writeObject(ObjectOutputStream out) throws IOException {
    37             throw new Error("bar.writeObject invoked");
    38             throw new Error("bar.writeObject invoked");
    38         }
    39         }
       
    40         @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    39         private void readObject(ObjectInputStream in)
    41         private void readObject(ObjectInputStream in)
    40             throws IOException, ClassNotFoundException
    42             throws IOException, ClassNotFoundException
    41         {
    43         {
    42             throw new Error("bar.readObject invoked");
    44             throw new Error("bar.readObject invoked");
    43         }
    45         }
       
    46         @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    44         Object writeReplace() throws ObjectStreamException {
    47         Object writeReplace() throws ObjectStreamException {
    45             throw new Error("bar.writeReplace invoked");
    48             throw new Error("bar.writeReplace invoked");
    46         }
    49         }
    47         // readResolve cannot be defined until Enum.readResolve is removed
    50         // readResolve cannot be defined until Enum.readResolve is removed
    48         // Object readResolve() throws ObjectStreamException {
    51         // Object readResolve() throws ObjectStreamException {
    49         //    throw new Error("bar.readResolve invoked");
    52         //    throw new Error("bar.readResolve invoked");
    50         // }
    53         // }
    51     };
    54     };
    52 
    55 
       
    56     @SuppressWarnings("serial") /* Incorrect use is being tested */
    53     private void writeObject(ObjectOutputStream out) throws IOException {
    57     private void writeObject(ObjectOutputStream out) throws IOException {
    54         throw new Error("Foo.writeObject invoked");
    58         throw new Error("Foo.writeObject invoked");
    55     }
    59     }
       
    60     @SuppressWarnings("serial") /* Incorrect use is being tested */
    56     private void readObject(ObjectInputStream in)
    61     private void readObject(ObjectInputStream in)
    57         throws IOException, ClassNotFoundException
    62         throws IOException, ClassNotFoundException
    58     {
    63     {
    59         throw new Error("Foo.readObject invoked");
    64         throw new Error("Foo.readObject invoked");
    60     }
    65     }
       
    66     @SuppressWarnings("serial") /* Incorrect use is being tested */
    61     Object writeReplace() throws ObjectStreamException {
    67     Object writeReplace() throws ObjectStreamException {
    62         throw new Error("Foo.writeReplace invoked");
    68         throw new Error("Foo.writeReplace invoked");
    63     }
    69     }
    64     // readResolve cannot be defined until Enum.readResolve is removed
    70     // readResolve cannot be defined until Enum.readResolve is removed
    65     // Object readResolve() throws ObjectStreamException {
    71     // Object readResolve() throws ObjectStreamException {