test/jdk/java/io/Serializable/InvalidClassException/noargctor/Serialize/SubclassAcrossPackage.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 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 import java.io.*;
    32 import java.io.*;
    33 
    33 
    34 class PublicSerializable
    34 class PublicSerializable
    35 extends NonSerializable.PublicCtor implements Serializable
    35 extends NonSerializable.PublicCtor implements Serializable
    36 {
    36 {
       
    37     private static final long serialVersionUID = 1L;
       
    38 
    37     int field1 = 5;
    39     int field1 = 5;
    38 };
    40 };
    39 
    41 
    40 class ProtectedSerializable
    42 class ProtectedSerializable
    41 extends NonSerializable.ProtectedCtor implements Serializable
    43 extends NonSerializable.ProtectedCtor implements Serializable
    42 {
    44 {
       
    45     private static final long serialVersionUID = 1L;
       
    46 
    43     int field1 = 5;
    47     int field1 = 5;
    44 };
    48 };
    45 
    49 
    46 class DifferentPackageSerializable
    50 class DifferentPackageSerializable
    47 extends NonSerializable.PackageCtor implements Serializable
    51 extends NonSerializable.PackageCtor implements Serializable
    48 {
    52 {
       
    53     private static final long serialVersionUID = 1L;
       
    54 
    49     int field1 = 5;
    55     int field1 = 5;
    50     DifferentPackageSerializable() {
    56     DifferentPackageSerializable() {
    51         super(1);
    57         super(1);
    52     }
    58     }
    53 };
    59 };
    54 
    60 
    55 class SamePackageSerializable
    61 class SamePackageSerializable
    56 extends Serialize.SamePackageCtor implements Serializable
    62 extends Serialize.SamePackageCtor implements Serializable
    57 {
    63 {
       
    64     private static final long serialVersionUID = 1L;
       
    65 
    58     SamePackageSerializable() {
    66     SamePackageSerializable() {
    59     }
    67     }
    60 };
    68 };
    61 
    69 
    62 class SamePackageProtectedCtor {
    70 class SamePackageProtectedCtor {
       
    71     private static final long serialVersionUID = 1L;
       
    72 
    63     protected SamePackageProtectedCtor() {
    73     protected SamePackageProtectedCtor() {
    64     }
    74     }
    65 };
    75 };
    66 
    76 
    67 class SamePackageProtectedSerializable
    77 class SamePackageProtectedSerializable
    68 extends Serialize.SamePackageProtectedCtor implements Serializable
    78 extends Serialize.SamePackageProtectedCtor implements Serializable
    69 {
    79 {
       
    80     private static final long serialVersionUID = 1L;
       
    81 
    70     SamePackageProtectedSerializable() {
    82     SamePackageProtectedSerializable() {
    71     }
    83     }
    72 };
    84 };
    73 
    85 
    74 
    86 
    75 class SamePackagePrivateCtor {
    87 class SamePackagePrivateCtor {
       
    88     private static final long serialVersionUID = 1L;
       
    89 
    76     private SamePackagePrivateCtor() {
    90     private SamePackagePrivateCtor() {
    77     }
    91     }
    78     public SamePackagePrivateCtor(int l) {
    92     public SamePackagePrivateCtor(int l) {
    79     }
    93     }
    80 };
    94 };
    81 
    95 
    82 class SamePackagePrivateSerializable
    96 class SamePackagePrivateSerializable
    83 extends Serialize.SamePackagePrivateCtor implements Serializable
    97 extends Serialize.SamePackagePrivateCtor implements Serializable
    84 {
    98 {
       
    99     private static final long serialVersionUID = 1L;
       
   100 
    85     SamePackagePrivateSerializable() {
   101     SamePackagePrivateSerializable() {
    86         super(1);
   102         super(1);
    87     }
   103     }
    88 };
   104 };
    89 
   105 
    90 class PrivateSerializable
   106 class PrivateSerializable
    91 extends NonSerializable.PrivateCtor implements Serializable
   107 extends NonSerializable.PrivateCtor implements Serializable
    92 {
   108 {
       
   109     private static final long serialVersionUID = 1L;
       
   110 
    93     int field1 = 5;
   111     int field1 = 5;
    94 
   112 
    95     PrivateSerializable() {
   113     PrivateSerializable() {
    96         super(1);
   114         super(1);
    97     }
   115     }
    98 };
   116 };
    99 
   117 
   100 class ExternalizablePublicCtor implements Externalizable {
   118 class ExternalizablePublicCtor implements Externalizable {
       
   119     private static final long serialVersionUID = 1L;
       
   120 
   101     public ExternalizablePublicCtor() {
   121     public ExternalizablePublicCtor() {
   102     }
   122     }
   103     public void writeExternal(ObjectOutput out) throws IOException {
   123     public void writeExternal(ObjectOutput out) throws IOException {
   104     }
   124     }
   105     public void readExternal(ObjectInput in)
   125     public void readExternal(ObjectInput in)
   106         throws IOException, ClassNotFoundException
   126         throws IOException, ClassNotFoundException
   107         {
   127         {
   108         }
   128         }
   109 };
   129 };
   110 
   130 
       
   131 @SuppressWarnings("serial") /* Incorrect declarations are being tested */
   111 class ExternalizableProtectedCtor implements Externalizable {
   132 class ExternalizableProtectedCtor implements Externalizable {
       
   133     private static final long serialVersionUID = 1L;
       
   134 
   112     protected ExternalizableProtectedCtor() {
   135     protected ExternalizableProtectedCtor() {
   113     }
   136     }
   114     public void writeExternal(ObjectOutput out) throws IOException {
   137     public void writeExternal(ObjectOutput out) throws IOException {
   115     }
   138     }
   116     public void readExternal(ObjectInput in)
   139     public void readExternal(ObjectInput in)
   117         throws IOException, ClassNotFoundException
   140         throws IOException, ClassNotFoundException
   118         {
   141         {
   119         }
   142         }
   120 };
   143 };
   121 
   144 
       
   145 @SuppressWarnings("serial") /* Incorrect declarations are being tested */
   122 class ExternalizablePackageCtor implements Externalizable {
   146 class ExternalizablePackageCtor implements Externalizable {
       
   147     private static final long serialVersionUID = 1L;
       
   148 
   123     ExternalizablePackageCtor() {
   149     ExternalizablePackageCtor() {
   124     }
   150     }
   125     public void writeExternal(ObjectOutput out) throws IOException {
   151     public void writeExternal(ObjectOutput out) throws IOException {
   126     }
   152     }
   127     public void readExternal(ObjectInput in)
   153     public void readExternal(ObjectInput in)
   128         throws IOException, ClassNotFoundException
   154         throws IOException, ClassNotFoundException
   129         {
   155         {
   130         }
   156         }
   131 };
   157 };
   132 
   158 
       
   159 @SuppressWarnings("serial") /* Incorrect declarations are being tested */
   133 class ExternalizablePrivateCtor implements Externalizable {
   160 class ExternalizablePrivateCtor implements Externalizable {
       
   161     private static final long serialVersionUID = 1L;
       
   162 
   134     private ExternalizablePrivateCtor() {
   163     private ExternalizablePrivateCtor() {
   135     }
   164     }
   136     public ExternalizablePrivateCtor(int i) {
   165     public ExternalizablePrivateCtor(int i) {
   137     }
   166     }
   138     public void writeExternal(ObjectOutput out) throws IOException {
   167     public void writeExternal(ObjectOutput out) throws IOException {