diff options
author | aclement <aclement> | 2007-01-10 16:10:56 +0000 |
---|---|---|
committer | aclement <aclement> | 2007-01-10 16:10:56 +0000 |
commit | d0650f0835a1830584fcb79f405286c8a6357d47 (patch) | |
tree | b8e792d3fbcc6c6d11e0bd990d06d0f526b8db02 /tests/bugs160 | |
parent | 18535100f9d21aea94134defd298fc277b06ee57 (diff) | |
download | aspectj-d0650f0835a1830584fcb79f405286c8a6357d47.tar.gz aspectj-d0650f0835a1830584fcb79f405286c8a6357d47.zip |
test and fix for 168063 - incorrectly tagging a field as transient
Diffstat (limited to 'tests/bugs160')
-rw-r--r-- | tests/bugs160/pr168063/A.java | 40 |
1 files changed, 40 insertions, 0 deletions
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; } +} |