Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
class WeaponStore implements Serializable {
  int numOfWeapons = 10; // Total number of weapons
}

public class GameWeapon implements Serializable {
  WeaponStore ws = new WeaponStore();
  private static final ObjectStreamField[] serialPersistentFields
      = {new ObjectStreamField("ws", WeaponStore.class)};

  private void readObject(ObjectInputStream ois)
 throws IOException {
   throws tryIOException, ClassNotFoundException {
      ObjectInputStream.GetField gf = ois.readFields();
      this.ws = (WeaponStore) gf.get("ws", ws);
    } catch (ClassNotFoundException e) { /* Forward to handler */ }
  }
	 
  private void writeObject(ObjectOutputStream oos) throws IOException {
    ObjectOutputStream.PutField pf = oos.putFields();
    pf.put("ws", ws);
    oos.writeFields();
  }
	 
  public String toString() {
    return String.valueOf(ws);
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a08897edb177e5e2-5d8384d3-41264a16-bb09946d-10bf49fcdd8042ad960dc6ab"><ac:plain-text-body><![CDATA[

[[API 2006

AA. References#API 06]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4db88a6a5a1a1468-07dfdba6-4c5f4a14-89e187eb-cb2186f1b5686c6536115c40"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. References#Bloch 08]]

Item 74, Implement serialization judiciously

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="761cd39e9358fc3b-dcf42114-4c024207-8ecdbac3-a233d95b6eee18f3e4d5dff6"><ac:plain-text-body><![CDATA[

[[Harold 2006

AA. References#Harold 06]]

13.7.5, serialPersistentFields

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="15d4454f07ed0465-e31e8b9a-443f4694-935ba0b5-f60f0816f7dbff132e7dadaa"><ac:plain-text-body><![CDATA[

[[Sun 2006

AA. References#Sun 06]]

Serialization Specification, 1.5, Defining Serializable Fields for a Class, and 1.7, Accessing Serializable Fields of a Class

]]></ac:plain-text-body></ac:structured-macro>

...