Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Annotations with RetentionPolicy = SOURCE

Yes, it is because of SOURCE retention policy. By the time AspectJ is
matching pointcuts it is working on class files - those that have been
produced by the compiler, and by this stage we have lost SOURCE level
annotations.  You could plug in some APT style thing I imagine, that
added another kind of annotation that Aj could see based on the source
level annotations - but I've never tried that myself.

Andy.

On 15/07/07, Tiago Moreiras <tiago.moreiras@xxxxxxxxxx> wrote:




Hi,



I'm developing a set of policies to enforce good practices, with AspectJ.
Today I run into a problem that, I suppose, is most likely to be a
limitation of AspectJ itself.



I was trying to match an annotation with Source retention in a declare
warning. Can I do this? I already search the notebook at:



http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-decp.html#declare-error-and-declare-warning



I noticed that, in declare parents, its explicitly referred that "it is now
possible to match types based on the presence of annotations with either
class-file or runtime retention". However nothing is said about Source
retention.



A simple test example that I developed is:



Class A and B:



public class A {

                public void foo() { //doSomething }

}



public class B extends A{

                @Override

                public void foo() { //doSomethingDifferent }

}



Aspect



public aspect Enforcer {

                declare warning: execution(@Override * *(..)) : "Overriding
Method!";

}



The problem here is the use of an Annotation with RetentionPolicy = SOURCE,
right? Is there any way of matching this annotations? Or is it really a
limitation of the language itself?



Regards,

Tiago Moreiras
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users





Back to the top