Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] weaving code after loops

Sven, you're right that there is no AspectJ pointcut to pick out any kind of loop (or if) statement executing. The reason is that pointcuts that picked out specific loops would be brittle in that programmers would expect to be able to change how foo is implemented (e.g., to for(;b;) { ...  } or to while (b&&c) {...}) without changing how aspects work. As Rickard said, why do you want to do this?

To use AspectJ with code like this, you could use the extract method refactoring, which would let you name a helper method to describe the post inner-loop behavior you want to advise.

Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895


> ------------Original Message------------
> From: "Sven Apel" <apel@xxxxxxxxxxxxxxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Wed, Sep-29-2004 9:09 AM
> Subject: [aspectj-users] weaving code after loops
>
> Hello everybody,
> 
> I want to weave code into the following example code:
> 
> void foo()
> {
> 	boolean a = true;
> 	boolean b = true;
> 
> 	while(a == true)
> 	{
> 		// do something
> 		while(b == true)
> 		{
> 			// do something
> 		}
> 	}
> }
> 
> I want to weave a call to method bar after the inner while-loop:
> 
> void foo()
> {
> 	boolean a = true;
> 	boolean b = true;
> 
> 	while(a == true)
> 	{
> 		// do something
> 		while(b == true)
> 		{
> 			// do something
> 		}
> 		bar(); // code to weave
> 	}
> }
> 
> In current I see no way how I can express this joinpoint using AspectJ. 
> Has
> anybody an idea?
> 
> best regards
> Sven
> 
> ------------------------------------
> Dipl.-Inf. Sven Apel
> 
> Universität Magdeburg:
> Tel.:   +49-(0)-391-67-11899
> Fax.:   +49-(0)-391-67-12020
> e-mail: apel@xxxxxxxxxxxxxxxxxxxxxxx
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 



Back to the top