Hi,
 We want to use annotations for advices and methods defined in the aspect. We 
need to post process the compiled aspect. Therefore, we need that the compiler 
keeps user-defined annotations.

I tried to add annotations with standard AspectJ, and it seems that the 
compiler keeps them. At least, the bytecode shows 1 annotation for doiIt() and 
2 annotations for ajc$before...(). I guess AspectJ already makes use of 
annotations for advices...(??)

import java.lang.annotation.*;
@Target(ElementType.METHOD)
    public @interface Test_Target {
        public String doTestTarget();
    }

 import java.lang.annotation.*;
aspect Foo {
   @Test_Target(doTestTarget="a method")
    public void doIt() {
        System.out.print("do it");
    }

    @Test_Target(doTestTarget="an advice")
    before() : call(* *.*(..)) && !within(Foo) {
        System.out.println(thisJoinPoint);
        doIt();
    }
}


Then, I tried @AspectJ, and I think my annotations were removed by the 
compiler... The compiled bytecode of the aspect has exactly the same annotation 
entries (RuntimeVisibleAnnotation) with or without my annotations.

import org.aspectj.lang.annotation.*;
import org.aspectj.lang.*;
@Aspect
    public class Foo {

        @Pointcut("call(* *.*(..)) && !within(Foo)")
            void anyCall() {}

           @Test_Target(doTestTarget="a method") // removed??
            public void doIt() {
                System.out.println("doIt");
        }

        @Test_Target(doTestTarget="an advice") // removed??? 
        @Before("anyCall()")
            public void beforeAnyCall(JoinPoint jp) {
            System.out.println(jp);
            doIt();
        }
    }

Is there a way to make ajc to keep user-redined annotations with @AspectJ ? Did 
I wrongly used my annotations? or should I keep using AspectJ, instead of 
@AspectJ ?


Many thanks,

Alex


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to