Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] finding static field declarations

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

It is not possible to generate compiler warnings or errors for field
declarations as aspectJ defines no join points for declarations. You
can, however, generate warnings and errors when any static fields are
set or referenced as follows:

aspect XAspect {
        declare warning:
                get(static * *) || set(static * *) : "Don't use static
variables!";
}

cheers,
 - Gijs Peek
Mike Schneider wrote:
> How would I write an aspect that would restrict the use of static fields?
> 
> Such that compiling something simple like this:
> 
> class X {
>     static int c; // bad
>     int d;          // ok
> }
> 
> 
> would result in a compiler warning/error for c, but not d.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIVAwUBRxmzK7b66fbjXztVAQI0Qw//X5ZOpJ4JUiWOaJLLfEeZ9VJGIW55CktD
GOt9AwPTutKxI2Qt6dBh0lTwqz2bhFI9vd7PFG9whHERsuSxUIG/sf4zsVbN9kwf
4oszZWV0bkxDarxZoh4OW/9GrEy4VDaww5Fh3bRQXdVrdnS+8Rs4CLzrB867DJST
CNIH5B+YA+DLYTHilfuDyQwhoECnSdsUKbmyIpERgjmp5GTQkNMrtRXz9H9KeLXK
UYHpUXTA2t5PoOG49g305KBHKp6uaoTqs2L+x9CSOpGiRYjz7YLCb7DouAJbfTwb
N9Z3l+RALGT/ibY1zw+O9YIZOSKY3Ao+1QxayZ7jlyu6lMr0zoNbf838HzaKM8HK
KbUrd6+dWG8w9vvrYJU2+NZ6Y9OxI9I1KwHxC+tI24zjr57Bn0FimF67vIPp3zUW
yqurqq1F7saGWYNOao7CghwO5kMiGElRJF9tQo5tpDYeZ3RZ3UORcjLXdYiGN0S1
MB1nUdxhwSYh2cw+qYhsLe43XngM4YzTag1wO53b+HDv3nilSwfQgqW6rZ5V9Kk1
GIjkwxhNilqEJdXsBX17jDkWPo2BNnXc0LXQ8AbM2oYbsewdxd1bV6GLJCU+Dfuc
MiTIbAw3IU1WCdk4NfKlMDkhhbC8BPac5fIslC2d2l9sM6TP+EIKuXX7NBjbbDCi
eV6+22TYJno=
=MmHK
-----END PGP SIGNATURE-----


Back to the top