[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] using @annotation to select annotated aspects


Does @annotation work on aspects too? I could not come up with a
working example.
Logically I assume that the call of simple2.foo is caught by the p1
pointcut in Test2, and
since Test2 is annoted with Annotation2 than the System.out.println
call should be
caught by Test1 / p8. Is this correct?

public @interface Annotation2 { }

public class Simple {
	public void foo2(){ System.err.print("foo2"); }

aspect Test1{
     pointcut p8() : @annotation(Annotation2);
     before () : p8() { System.out.println("p8");

aspect Test2{
	pointcut p1() : call(void Simple.foo2());
	before () : p1(){ System.err.println("lexical2"); }

public class Main{
   public static void main(String[]args){
       Simple s = new Simple();

Many thanks,