|newbie question [message #49688]
||Wed, 09 March 2005 11:02
Originally posted by: hmcbride.curamsoftware.com|
Am quite new to aop , currently investigating the use of eclipse and
aspectj for detecting illegal method calls ( i.e policy enforcement).
There is a code pattern
that we are looking to detect , a double for loop that contains certain
set methods i.e.
for(int i = 0; i< 10; i++)
for(int j = 0; j< 10; j++)
this to prevent certain variable from being overwritten.
Is there any way I can detect this type of construct using aop.
Any pointers /suggestions welcome
thanks in advance
|Re: newbie question [message #587353 is a reply to message #49688]
||Wed, 09 March 2005 12:35
Originally posted by: Rafal.Krzewski.caltha.pl|
Hugh McBride wrote:
> There is a code pattern that we are looking to detect , a double for
> loop that contains certain set methods i.e.
> for(int i = 0; i< 10; i++)
> for(int j = 0; j< 10; j++)
> this to prevent certain variable from being overwritten.
> Is there any way I can detect this type of construct using aop.
It is a valid use case for AOP, but AFAICT it is impossible to do this
The problem is the implemented join point model. In AOP there are many
kinds of join points, including for loop body execution. Actual AOP
implementations, like AspectJ support only a subset of the possible join
points that can be matched by pointcuts in your aspects. The joinpoints
that are left out are those that cannot be reliably described: If you
have several loops in a single method, how do you describe in the
pointcut which loop do you mean?
At this point AspectJ does not provide a pointcut for picking out code
blocks (like loop or conditional bodies), so you won't be able to detect
that anti-pattern with AspectJ.
Powered by FUDForum
. Page generated in 0.15411 seconds