Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Customized annotations @AspectJ vs AspectJ

I didn't write that area of the code but I believe whatever route you
use to define the aspect, if it is compiled with ajc, the AspectJ
annotations will be added and that enables the AspectJ reflection
interface to work (AjType/etc).

As Wim says, make sure your annotations are of appropriate retention,
raise a bug if they are still discarded.

Andy

2009/5/11 Villazón Alex <alex.villazon@xxxxxxxxxxx>:
> 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
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top