1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package failureAtomicity.foo.foo; 24 25 import failureAtomicity.Expose; 26 27 import java.io.IOException; 28 import java.io.Serializable; 29 30 // foo.foo.HomeAddress and bar.bar.HomeAddress are identical, other than the 31 // type of their zebra field. 32 33 public final class HomeAddress extends Address implements Serializable { 34 static final long serialVersionUID = -0L; 35 36 public final int houseNumber; 37 public final String zebra; // ordered alphabetically, must be last 38 39 public HomeAddress(int houseNumber, String city, String county, String country, byte[] zebra) { 40 super(city, county, country); 41 this.houseNumber = houseNumber; 42 this.zebra = "bad"; 43 } 44 45 @Override 46 public String toString() { 47 return new StringBuilder() 48 .append("houseNumber:").append(houseNumber) 49 .append(", city:").append(city) 50 .append(", county:").append(county) 51 .append(", country:").append(country) 52 .append(", zebra:").append(zebra) 53 .toString(); 54 } 55 } 56 57 class Address implements Serializable { 58 static final long serialVersionUID = -0L; 59 60 public final String city; 61 public final String county; 62 public final String country; 63 public final Expose expose; // So we can retrieve a reference to check 64 65 public Address(String city, String county, String country) { 66 this.country = country; 67 this.city = city; 68 this.county = county; 69 this.expose = new Expose(this); 70 } 71 72 // private void readObject(java.io.ObjectInputStream in) 73 // throws IOException, ClassNotFoundException 74 // { 75 // in.defaultReadObject(); 76 // } 77 }