From d0650f0835a1830584fcb79f405286c8a6357d47 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 10 Jan 2007 16:10:56 +0000 Subject: test and fix for 168063 - incorrectly tagging a field as transient --- tests/bugs160/pr168063/A.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/bugs160/pr168063/A.java (limited to 'tests/bugs160') diff --git a/tests/bugs160/pr168063/A.java b/tests/bugs160/pr168063/A.java new file mode 100644 index 000000000..c4831ff9d --- /dev/null +++ b/tests/bugs160/pr168063/A.java @@ -0,0 +1,40 @@ +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + + +public class A { + public static void main(String[] args) throws Exception { + A obj1 = new A(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(obj1); + oos.close(); + byte[] data = baos.toByteArray(); + + ByteArrayInputStream bais = new ByteArrayInputStream(data); + ObjectInputStream ois = new ObjectInputStream(bais); + Object o = ois.readObject(); + + int before = ((Persistable)obj1).getPersistableId(); + int after = ((Persistable)o).getPersistableId(); + if (before!=after) + System.out.println("The data was lost! before="+before+" after="+after); + else + System.out.println("It worked, data preserved!"); + } +} + +interface Persistable extends Serializable { + abstract public int getPersistableId(); +} + +aspect PersistableImpl { + declare parents: A extends Persistable; + + final public int Persistable.persistableId = 42; + public int Persistable.getPersistableId() { return persistableId; } +} -- cgit v1.2.3