diff options
Diffstat (limited to 'tests/new/SerializedOf.java')
-rw-r--r-- | tests/new/SerializedOf.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/new/SerializedOf.java b/tests/new/SerializedOf.java new file mode 100644 index 000000000..fd58d8d71 --- /dev/null +++ b/tests/new/SerializedOf.java @@ -0,0 +1,42 @@ +import org.aspectj.testing.Tester; +import java.io.*; + + +public class SerializedOf { + public static void main(String[] args) throws Exception { + C c = new C(); + + Tester.check(ASer.hasAspect(c), "ASer on original"); + Tester.check(ANoSer.hasAspect(c), "ANoSer on original"); + + + File tmp = File.createTempFile("cdata", "ser"); + FileOutputStream ostream = new FileOutputStream(tmp); + ObjectOutputStream p = new ObjectOutputStream(ostream); + p.writeObject(c); + p.flush(); + ostream.close(); + + + FileInputStream istream = new FileInputStream(tmp); + ObjectInputStream p1 = new ObjectInputStream(istream); + C newC = (C)p1.readObject(); + istream.close(); + + Tester.check(ASer.hasAspect(newC), "ASer after read"); + Tester.check(!ANoSer.hasAspect(newC), "no ANoSer after read"); + } +} + +class C implements Serializable { + int data = 42; +} + + +aspect ASer implements Serializable pertarget(target(C)) { + int serData = 20; +} + +aspect ANoSer pertarget(target(C+)) { + int noSerData = 21; +} |