summaryrefslogtreecommitdiffstats
path: root/tests/new/PR355.java
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/PR355.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/PR355.java')
-rw-r--r--tests/new/PR355.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/new/PR355.java b/tests/new/PR355.java
new file mode 100644
index 000000000..5c9d4fa0e
--- /dev/null
+++ b/tests/new/PR355.java
@@ -0,0 +1,56 @@
+import org.aspectj.testing.*;
+import java.io.*;
+
+public class PR355 {
+ public static void main(String[] args) {
+ new PR355().go();
+ }
+
+ static {
+ String[] types = { "static", "non", "instance" };
+ String[] advice = { "before", "after", "around" };
+ for (int i = 0; i < types.length; i++) {
+ for (int j = 0; j < advice.length; j++) {
+ Tester.expectEvent(types[i] + "-" + advice[j]);
+ }
+ }
+ Tester.expectEventsInString("C.f,C.e");
+ }
+
+ void go() {
+ new C().f();
+ Tester.checkAllEvents();
+ }
+}
+
+
+class C {
+ void f() { Tester.event("C.f"); e(); }
+ void e() { Tester.event("C.e"); }
+}
+
+abstract aspect Cuts {
+ pointcut p(): within(C) && call(* C.*(..));
+ static void a(String s) { Tester.event(s); }
+}
+
+/* Static aspects have no problem */
+aspect StaticAspect extends Cuts {
+ before(): p() { a("static-before"); }
+ void around(): p() { a("static-around"); proceed(); }
+ after (): p() { a("static-after"); }
+}
+
+/* Non-static aspects have a problem */
+aspect NonStaticAspect extends Cuts issingleton() {
+ before(): p() { a("non-before"); }
+ void around(): p() { a("non-around"); proceed(); }
+ after (): p() { a("non-after"); }
+}
+
+/* No problem here */
+aspect InstanceOfAspect extends Cuts perthis(this(C)) {
+ before(): p() { a("instance-before"); }
+ void around(): p() { a("instance-around"); proceed(); }
+ after (): p() { a("instance-after"); }
+}