[aspectc-user] aspect conflict resolution

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Mon Jun 16 18:03:24 CEST 2003


HI,

Olaf Spinczyk wrote:
> Hi Matthias,
> 
> mathias.kurth at s2000.tu-chemnitz.de wrote:
> 
>> Hello,
>>
>> I've got a question about aspect conflict resolution in AspectC++. I 
>> have the following aspects:
>>
>>     aspect Outer1 {
>>       pointcut virtual p() = 0;
>>             advice p() : before() {
>>         printf("before p in Outer1\n");
>>       }
>>     };
>>
>>     aspect Outer2 : public Outer1 {
>>       pointcut virtual p() = call("% %::Print(...)");
>>     
>>       advice p() : before() {
>>         printf("before p in Outer2\n");
>>       }
>>     };
>>     
>> How is the order of the advices to p() defined?
>> In AspectJ it is said that all advices in the derived class
>> do have prefenence over the advices in the base class.
>> I've tried to apply this to the aspect compiler, but
>> the result was the following:
>>
>>     static inline void a0_before_Outer2_call_main_FiiPPcE_0() {
>>         printf("before p in Outer2\n");
>>     }
>>     static inline void a0_before_Outer2_call_main_FiiPPcE_0() {
>>         printf("before p in Outer1\n");
>>     }
>>     static inline void __call_main_FiiPPcE_0_0 (::test::CAspectTest1 
>> *dstthis) {
>>         a0_before_Outer2_call_main_FiiPPcE_0();
>>         a0_before_Outer2_call_main_FiiPPcE_0();
>>         dstthis->Print ();
>>     }
>>
>> I think this is surely not the expected result. The generated
>> output was not compileable with the backend compiler.
> 
> 
> This is a code generation bug. I added it to bugzilla (bug 99). We will 
> fix this problem as soon as possible.
> 
>> Another point is what would be if the pointcut was not virtual.
>> How is the order defined if the base and the derived aspects
>> do advice to some pointcuts which include the same join points?
> 
> 
> There is no rule, which defines the order of advice execution, in 
> AspectC++, yet. However, our goal is/was to adopt the AspectJ default 
> ordering, but, for example, before advice of a base aspect is executed 
> after before advice on the same join point in the derived aspect.
> 
> This behavior will change in the near future and a section on advice 
> ordering will be added to the reference manual, which defines a default 
> ordering rule that you can rely on.

I'm sorry, I was a bit confused, when I wrote this. As you said: in 
AspectJ the advice of the derived aspect has precedence. That's the way 
how it is implemented in AspectC++ as well. The only problem was the 
code generation bug, which is BTW already fixed.

However, we still have to check and document the other precedence rules.

Yours,

Olaf




More information about the aspectc-user mailing list