]> source.dussan.org Git - aspectj.git/commitdiff
Tests for static method call/execution with @annotation
authoraclement <aclement>
Mon, 31 Jan 2005 14:02:38 +0000 (14:02 +0000)
committeraclement <aclement>
Mon, 31 Jan 2005 14:02:38 +0000 (14:02 +0000)
tests/java5/annotations/binding/StaticMethods.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java

diff --git a/tests/java5/annotations/binding/StaticMethods.java b/tests/java5/annotations/binding/StaticMethods.java
new file mode 100644 (file)
index 0000000..385ea70
--- /dev/null
@@ -0,0 +1,28 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored {String value();}
+
+
+public class StaticMethods {
+
+  public static void main(String[] argv) {
+    m1();
+    m2();
+  }
+
+
+  @Colored("red")  static void m1() {System.err.println("m1 running");}
+  @Colored("blue") static void m2() {System.err.println("m2 running");}
+
+  static aspect X {
+    before(Colored c): call(* m*(..)) && @annotation(c) {
+      System.err.println("Color at "+thisJoinPoint+" is "+c.value());
+    }
+    before(Colored c): execution(* m*(..)) && @annotation(c) {
+      System.err.println("Color at "+thisJoinPoint+" is "+c.value());
+    }
+  }
+
+}
+
index 0af6b4560b51f32bc08004e8c595955906bd36f9..b1fd803bce0a79f4aa60d07bbd84e41e9e9ba122 100644 (file)
@@ -144,4 +144,11 @@ public class AnnotationBinding extends TestUtils {
        assertMessages(cR,new EmptyMessageSpec());
        RunResult rR = run("a.b.c.A");
   }
+  
+  // Binding with calls/executions of static methods
+  public void testCallsAndExecutionsOfStaticMethods() {
+       CompilationResult cR = ajc(baseDir,new String[]{"StaticMethods.java","-1.5","-d","."});
+       assertMessages(cR,new EmptyMessageSpec());
+       RunResult rR = run("StaticMethods");
+  }
 }
\ No newline at end of file