summaryrefslogtreecommitdiff
path: root/sources/simulator
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-06-03 16:41:37 +0000
committerPaul Buetow <paul@buetow.org>2008-06-03 16:41:37 +0000
commit11af1c9fa7fe66e10de0a92878311b4e22befb0f (patch)
tree8dfc7af2ec18eb5889327426bc6fdb7379a3feba /sources/simulator
parentf7bdf8a7f6ebd43bfacc22eeeda3eb52bf50efd7 (diff)
made future serialized class versions backwards compatible.
Diffstat (limited to 'sources/simulator')
-rw-r--r--sources/simulator/VSSimulator.java14
-rw-r--r--sources/simulator/VSSimulatorCanvas.java14
-rw-r--r--sources/simulator/VSSimulatorFrame.java4
3 files changed, 29 insertions, 3 deletions
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index aec330e..0a7c6c2 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -1232,7 +1232,14 @@ public class VSSimulator extends JPanel implements VSSerializable {
public synchronized void serialize(VSSerialize serialize,
ObjectOutputStream objectOutputStream)
throws IOException {
+ /** For later backwards compatibility, to add more stuff */
+ objectOutputStream.writeObject(new Boolean(false));
+
simulatorCanvas.serialize(serialize, objectOutputStream);
+
+ /** For later backwards compatibility, to add more stuff */
+ objectOutputStream.writeObject(new Boolean(false));
+
}
/* (non-Javadoc)
@@ -1248,8 +1255,15 @@ public class VSSimulator extends JPanel implements VSSerializable {
serialize.setObject("simulator", this);
serialize.setObject("logging", logging);
+
+ /** For later backwards compatibility, to add more stuff */
+ objectInputStream.readObject();
+
simulatorCanvas.deserialize(serialize, objectInputStream);
+ /** For later backwards compatibility, to add more stuff */
+ objectInputStream.readObject();
+
updateFromPrefs();
updateTaskManagerTable();
}
diff --git a/sources/simulator/VSSimulatorCanvas.java b/sources/simulator/VSSimulatorCanvas.java
index 1b30a51..b521fc7 100644
--- a/sources/simulator/VSSimulatorCanvas.java
+++ b/sources/simulator/VSSimulatorCanvas.java
@@ -1571,6 +1571,9 @@ public class VSSimulatorCanvas extends Canvas
public synchronized void serialize(VSSerialize serialize,
ObjectOutputStream objectOutputStream)
throws IOException {
+ /** For later backwards compatibility, to add more stuff */
+ objectOutputStream.writeObject(new Boolean(false));
+
synchronized (processes) {
objectOutputStream.writeObject(new Integer(numProcesses));
for (VSProcess process : processes)
@@ -1578,6 +1581,9 @@ public class VSSimulatorCanvas extends Canvas
}
taskManager.serialize(serialize, objectOutputStream);
+
+ /** For later backwards compatibility, to add more stuff */
+ objectOutputStream.writeObject(new Boolean(false));
}
/* (non-Javadoc)
@@ -1591,6 +1597,9 @@ public class VSSimulatorCanvas extends Canvas
if (VSSerialize.DEBUG)
System.out.println("Deserializing: VSSimulatorCanvas");
+ /** For later backwards compatibility, to add more stuff */
+ objectInputStream.readObject();
+
int num = ((Integer) objectInputStream.readObject()).intValue();
logging.clear();
@@ -1604,8 +1613,11 @@ public class VSSimulatorCanvas extends Canvas
}
for (int i = 0; i < num; ++i)
- processes.get(0).deserialize(serialize, objectInputStream);
+ processes.get(i).deserialize(serialize, objectInputStream);
taskManager.deserialize(serialize, objectInputStream);
+
+ /** For later backwards compatibility, to add more stuff */
+ objectInputStream.readObject();
}
}
diff --git a/sources/simulator/VSSimulatorFrame.java b/sources/simulator/VSSimulatorFrame.java
index 2b9042c..ad095c4 100644
--- a/sources/simulator/VSSimulatorFrame.java
+++ b/sources/simulator/VSSimulatorFrame.java
@@ -149,8 +149,8 @@ public class VSSimulatorFrame extends VSFrame {
VSSerialize serialize = new VSSerialize();
VSSimulator simulator = serialize.openSimulator(
VSSimulatorFrame.this);
- if (simulator != null)
- addSimulator(simulator);
+ if (simulator != null)
+ addSimulator(simulator);
} else if (sourceText.equals(
finalPrefs.getString("lang.save"))) {