Hi John, Basically you are interested in a set() or a get() when it is not withincode() of a getter or setter (or likely constructor).
The problem is that you can't tie the methods name and the fields name together, so you either have to specify a completely wild policy: declare warning: get(* X.*) && !withincode(* get*(..)): "Use the getter to access fields on type X"; (which may warn on things you don't mind about) or specify a warning per field: declare warning: get(* X.foo) && !withincode(* X.getFoo(..)): "Use getFoo() to access the foo field"; As I say you may need to add an extra clause to ignore constructors since field initialization will typically done there. cheers Andy On 15 May 2011 04:08, John <rohanbha...@hotmail.com> wrote: > I have a doubt again. > > I need to enforce a policy that issues a warning when a variable's value is > accessed without using its corresponding setters and getters..... > > Not even sure where to start on this one.... > > > -- > View this message in context: > http://aspectj.2085585.n4.nabble.com/Policy-enforcement-for-setter-and-getter-methods-aspectj-tp3524161p3524161.html > Sent from the AspectJ - users mailing list archive at Nabble.com. > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users > _______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users