diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/AddObjectMethodProblem.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/AddObjectMethodProblem.java')
-rw-r--r-- | tests/new/AddObjectMethodProblem.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/new/AddObjectMethodProblem.java b/tests/new/AddObjectMethodProblem.java new file mode 100644 index 000000000..d218f77af --- /dev/null +++ b/tests/new/AddObjectMethodProblem.java @@ -0,0 +1,48 @@ +import org.aspectj.testing.Tester; + +public class AddObjectMethodProblem { + + // Uncommenting this and changing addObject -> doAddObject in the advice + // works around the bug 0.5beta1 + //public void doAddObject(Class1 o) { + // addObject(o); + //} + + public static void main(String[] args) { test(); } + + crosscut ccut(Class1 c1): c1 && void process(); + + advice(Class1 c1): ccut(c1) { + before { + if (c1.getElement() != null) addObject(c1.getElement()); + c1.setProcessedAndAdvised(true); + } + } + + public static void test() { + AddObjectMethodProblem a = new AddObjectMethodProblem(); + Class1 c1 = new Class1(); + Class1 c2 = new Class1(); + c1.element = c2; + a.addObject(c1); + c1.process(); + Tester.check(c1.processedAndAdvised, "advice on top"); + Tester.check(c2.processedAndAdvised, "advice on element"); + } +} + +class Class1 { + public Class1 element; + public boolean processedAndAdvised = false; + + public Class1 getElement() { return element; } + + public void setProcessedAndAdvised( boolean val ) { + processedAndAdvised = val; + } + + public void process() { + if (element != null) element.process(); + } +} + |