From 234bea2297cc780d5bf38ebbc4087e938cc3b6e8 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 12 Oct 2004 16:24:10 +0000 Subject: 76030 - cflow optimizations. Part 2 fix - share counters and stacks when we can. --- tests/cflow/CounterTest05.java | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/cflow/CounterTest05.java (limited to 'tests/cflow/CounterTest05.java') diff --git a/tests/cflow/CounterTest05.java b/tests/cflow/CounterTest05.java new file mode 100644 index 000000000..44c4b3ecc --- /dev/null +++ b/tests/cflow/CounterTest05.java @@ -0,0 +1,51 @@ +public class CounterTest05 { + +/* + * Here we have an abstract pointcut that is used within a cflow. In the two concrete sub-aspects + * we make the abstract pointcut concrete. The aim of the test is to ensure we do not share + * the cflow counter objects, since the pointcut within the cflow() in each case points at a + * different 'entry' point. The count should be 10 when we finish. If it is 8 we have shared + * a counter. + */ + public static void main(String []argv) { + print(); + print(); + below1(); + System.err.println("ctr="+A.ctr); + if (A.ctr!=10) + throw new RuntimeException("Counter should be 10 but is "+A.ctr); + } + + public static void below1() { + print(); + print(); + below2(); + } + + public static void below2() { + print(); + print(); + } + +public static void print() {} +} + +abstract aspect A { + public static int ctr = 0; + + abstract pointcut abs(); + + pointcut p(): call(* print(..)) && cflow(abs()); + + before(): p() { + A.ctr++; + } +} + +aspect B extends A { + pointcut abs(): execution(* main(..)); // ctr increases by 6 +} + +aspect C extends A { + pointcut abs(): execution(* below1(..)); // ctr increases by 4 +} -- cgit v1.2.3