test/jdk/java/io/Serializable/oldTests/ValidateClass.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 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.
    62             ObjectInputStream q = new ObjectInputStream(istream);
    62             ObjectInputStream q = new ObjectInputStream(istream);
    63 
    63 
    64             Validator vc_u;
    64             Validator vc_u;
    65 
    65 
    66             vc_u = (Validator)q.readObject();
    66             vc_u = (Validator)q.readObject();
    67             if (vc_u.validated != Integer.MIN_VALUE) {
    67             if (Validator.validated != Integer.MIN_VALUE) {
    68                 System.err.println("\nTEST FAILED: Validation callbacks did " +
    68                 System.err.println("\nTEST FAILED: Validation callbacks did " +
    69                     "not complete.");
    69                     "not complete.");
    70                 throw new Error();
    70                 throw new Error();
    71             }
    71             }
    72             istream.close();
    72             istream.close();
    78         }
    78         }
    79     }
    79     }
    80 }
    80 }
    81 
    81 
    82 class MissingWriterClass implements java.io.Serializable {
    82 class MissingWriterClass implements java.io.Serializable {
       
    83     private static final long serialVersionUID = 1L;
    83     int i = 77;
    84     int i = 77;
    84 
    85 
    85     private void writeObject(ObjectOutputStream pw) throws IOException {
    86     private void writeObject(ObjectOutputStream pw) throws IOException {
    86         pw.writeInt(i);
    87         pw.writeInt(i);
    87     }
    88     }
    88 }
    89 }
    89 
    90 
    90 class MissingReaderClass implements java.io.Serializable {
    91 class MissingReaderClass implements java.io.Serializable {
       
    92     private static final long serialVersionUID = 1L;
    91     int i = 77;
    93     int i = 77;
    92 
    94 
    93     private void readObject(ObjectInputStream pr) throws IOException {
    95     private void readObject(ObjectInputStream pr) throws IOException {
    94         i = pr.readInt();
    96         i = pr.readInt();
    95     }
    97     }
    96 }
    98 }
    97 
    99 
    98 
   100 
    99 class Validator implements ObjectInputValidation, java.io.Serializable  {
   101 class Validator implements ObjectInputValidation, java.io.Serializable  {
       
   102     private static final long serialVersionUID = 1L;
       
   103 
   100     static int validated = Integer.MAX_VALUE; // Last value validated
   104     static int validated = Integer.MAX_VALUE; // Last value validated
   101     int priority;
   105     int priority;
   102     Validator next = null;
   106     Validator next = null;
   103 
   107 
   104     public Validator(int prio, Validator n) {
   108     public Validator(int prio, Validator n) {