[aspectc-user] Aspect Inheritance

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Wed May 28 09:55:02 CEST 2003


Hi Sven,

Sven.Apel at metop-md.de wrote:
> Hi,
> 
> Is it possible to inherit from an aspect with a non-pure-virtual
> pointcut?
> Something like this:
> 
> aspect aAspect
> {
> 	pointcut virtual locking() =	execution("%
> Attribute::Set(...)");
> };
> 
> aspect bAspect : public aAspect
> {
> 	pointcut locking() =	execution("% Attribute::Get(...)");
> };
> 
> 
> If I try I get the following Message:
> 
> u:\Entwicklung\Eigene Projekte\DB_Aspects\LockBaseAspect.h(46): error:
> base aspect 'aAspect' is not abstract
> 
> If it is planned to support such inheritance, how can I reuse the
> pointcut declaration of the base class?
> I would appreciate something like that:
> 
> aspect bAspect : public aAspect
> {
> 	pointcut locking() =	execution("% Attribute::Get(...)") &&
> aAspect::locking();
> };
> 
> best regards
> Sven
> 
> p.s. Would it be nessecary in this case to declare the base class
> pointcut as virtual?

At the moment you can only inherit from abstract aspects, which means 
that it has to have at least one pure virtual pointcut or function. This 
rule is taken from the AspectJ semantics. It is quite conservative and 
it is possible that we will have a less restrictive rule in future releases.

Maybe it helps in your case that pointcuts don't have to be defined 
inside of aspects. They can be class members or even globals. For 
pointcuts the same lookup rules as for ordinary variables are applied. 
For example, if a pointcut is defined in a base class you don't have to 
provide 'classname::' in front of its name.

Yours,

Olaf




More information about the aspectc-user mailing list