aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/InnerClassNaming.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/InnerClassNaming.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/InnerClassNaming.java')
-rw-r--r--tests/new/InnerClassNaming.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/new/InnerClassNaming.java b/tests/new/InnerClassNaming.java
new file mode 100644
index 000000000..bf0ec54e7
--- /dev/null
+++ b/tests/new/InnerClassNaming.java
@@ -0,0 +1,50 @@
+import java.awt.*;
+import java.awt.event.*;
+import org.aspectj.testing.Tester;
+
+/*
+ * I would like to listen to events fired by a whiteboard swing widget.
+ * When I listen to method invocations from the widget itself in
+ * an aspect,
+ * there
+ * is no problem (like say getPreferredSize()).
+ *
+ * But, when I want to listen to events fired by a mouse adapter
+ * from which
+ * I derived
+ * an inner class in the whiteboard like this :
+ *
+ * SOLUTION: Replace all super.inner to super$inner.
+ */
+
+public class InnerClassNaming {
+ public static void main(String[] args) {
+ new InnerClassNaming();
+ }
+
+ InnerClassNaming() {
+ MouseListener listener = new MyListener();
+ addMouseListener(listener);
+ }
+
+ void addMouseListener(MouseListener listener) {}
+
+ class MyListener extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ System.out.println("mousPressed: " + e);
+ }
+ }
+}
+
+aspect MyAspect /*of eachobject(instanceof(InnerClassNaming.MyListener))*/ {
+
+ pointcut pressed(InnerClassNaming.MyListener ls):
+ //instanceof(ls) && executions(* mousePressed(..));
+ this(InnerClassNaming.MyListener) &&
+ target(ls) &&
+ execution(* mousePressed(..));
+
+ before(InnerClassNaming.MyListener ls): pressed(ls) {
+ System.out.println(thisJoinPoint);
+ }
+}