[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] Policy enforcement for setter and getter methods aspectj
|
- From: Andy Clement <andrew.clement@xxxxxxxxx>
- Date: Mon, 16 May 2011 07:51:04 -0700
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=bGOtxvWuaALqZSKOTa381SjUWdck9ggiVupqfA6/rVo=; b=iGmN/9Gr6UvJ85lSS/NLQBh/EkvOrTjSRXynOP3cQZ9d2PFlebmfFTPyEYEgGB+qas +0wsKuiUvkTAvnDKbbVuBHo2Dhn2Cx/DSlTGr1FtkUiiyk6BPqgaA/s/PYZ22TaqNjxu RteMiiHgNcrDnD8FXpHF9DwnPmSb23poUof2I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=cDfuBUu8tnNIOz5tc/CYLTOF6IWvw7ytWo24WY6/BERmwvBnmYGwkV+8Cj8rTUEDrg JPUwx33mDBGjTC/XtmzmE3ESMLxx4zcxM6ctxwSJxPoHb/n5aas4hVWByrjg56BR35Xo 1Pza5o81w7L82DkVmpqiia9UeKdr4D8kuK7Io=
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 <rohanbhatia@xxxxxxxxxxx> 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@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>