test/jdk/java/io/Serializable/skipToEndOfBlockData/SkipToEndOfBlockData.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 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.
    30  */
    30  */
    31 
    31 
    32 import java.io.*;
    32 import java.io.*;
    33 
    33 
    34 class MismatchedRead implements Serializable {
    34 class MismatchedRead implements Serializable {
       
    35     private static final long serialVersionUID = 1L;
       
    36 
    35     int i;
    37     int i;
    36     float f;
    38     float f;
    37 
    39 
    38     MismatchedRead(int i, float f) {
    40     MismatchedRead(int i, float f) {
    39         this.i = i;
    41         this.i = i;
    57         if (! (obj instanceof MismatchedRead))
    59         if (! (obj instanceof MismatchedRead))
    58             return false;
    60             return false;
    59         MismatchedRead other = (MismatchedRead) obj;
    61         MismatchedRead other = (MismatchedRead) obj;
    60         return (i == other.i && f == other.f);
    62         return (i == other.i && f == other.f);
    61     }
    63     }
       
    64 
       
    65     public int hashCode() {
       
    66         return i;
       
    67     }
    62 }
    68 }
    63 
    69 
    64 class MismatchedReadExternal implements Externalizable {
    70 class MismatchedReadExternal implements Externalizable {
       
    71     private static final long serialVersionUID = 1L;
       
    72 
    65     int i;
    73     int i;
    66     float f;
    74     float f;
    67 
    75 
    68     public MismatchedReadExternal() {
    76     public MismatchedReadExternal() {
    69         this(0, (float) 0.0);
    77         this(0, (float) 0.0);
    89         if (! (obj instanceof MismatchedReadExternal))
    97         if (! (obj instanceof MismatchedReadExternal))
    90             return false;
    98             return false;
    91         MismatchedReadExternal other = (MismatchedReadExternal) obj;
    99         MismatchedReadExternal other = (MismatchedReadExternal) obj;
    92         return (i == other.i && f == other.f);
   100         return (i == other.i && f == other.f);
    93     }
   101     }
       
   102 
       
   103     public int hashCode() {
       
   104         return i;
       
   105     }
    94 }
   106 }
    95 
   107 
    96 class InnocentBystander implements Serializable {
   108 class InnocentBystander implements Serializable {
       
   109     private static final long serialVersionUID = 1L;
       
   110 
    97     String s;
   111     String s;
    98 
   112 
    99     InnocentBystander(String s) {
   113     InnocentBystander(String s) {
   100         this.s = s;
   114         this.s = s;
   101     }
   115     }
   105             return false;
   119             return false;
   106         InnocentBystander other = (InnocentBystander) obj;
   120         InnocentBystander other = (InnocentBystander) obj;
   107         if (s != null)
   121         if (s != null)
   108             return s.equals(other.s);
   122             return s.equals(other.s);
   109         return (s == other.s);
   123         return (s == other.s);
       
   124     }
       
   125 
       
   126     public int hashCode() {
       
   127         return s.hashCode();
   110     }
   128     }
   111 }
   129 }
   112 
   130 
   113 public class SkipToEndOfBlockData {
   131 public class SkipToEndOfBlockData {
   114     public static void main(String[] args) throws Exception {
   132     public static void main(String[] args) throws Exception {