test/jdk/java/io/Serializable/enum/ignoreSerializationFields/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.
    32 
    32 
    33 enum Foo {
    33 enum Foo {
    34 
    34 
    35     foo,
    35     foo,
    36     bar {
    36     bar {
       
    37         @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    37         private static final long serialVersionUID = 2L;
    38         private static final long serialVersionUID = 2L;
    38         // bar is implemented as an inner class instance, so the following
    39         // bar is implemented as an inner class instance, so the following
    39         // declaration would cause a compile-time error
    40         // declaration would cause a compile-time error
    40         // private static final ObjectStreamField[] serialPersistentFields = {
    41         // private static final ObjectStreamField[] serialPersistentFields = {
    41         //    new ObjectStreamField("gub", Float.TYPE)
    42         //    new ObjectStreamField("gub", Float.TYPE)
    42         // };
    43         // };
    43     };
    44     };
    44 
    45 
       
    46     @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    45     private static final long serialVersionUID = 1L;
    47     private static final long serialVersionUID = 1L;
       
    48 
       
    49     @SuppressWarnings("serial") /* Incorrect declarations are being tested */
    46     private static final ObjectStreamField[] serialPersistentFields = {
    50     private static final ObjectStreamField[] serialPersistentFields = {
    47         new ObjectStreamField("blargh", Integer.TYPE)
    51         new ObjectStreamField("blargh", Integer.TYPE)
    48     };
    52     };
    49 }
    53 }
    50 
    54 
    51 public class Test {
    55 public class Test {
    52     public static void main(String[] args) throws Exception {
    56     public static void main(String[] args) throws Exception {
    53         Class[] classes =
    57         Class<?>[] classes =
    54             { Foo.class, Foo.foo.getClass(), Foo.bar.getClass() };
    58             { Foo.class, Foo.foo.getClass(), Foo.bar.getClass() };
    55         for (int i = 0; i < classes.length; i++) {
    59         for (int i = 0; i < classes.length; i++) {
    56             ObjectStreamClass desc = ObjectStreamClass.lookup(classes[i]);
    60             ObjectStreamClass desc = ObjectStreamClass.lookup(classes[i]);
    57             if (desc.getSerialVersionUID() != 0L) {
    61             if (desc.getSerialVersionUID() != 0L) {
    58                 throw new Error(
    62                 throw new Error(