[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-dev] Multiple inheritance for aspects in aspectj
|
AspectJ does not really support multiple inheritance. It only supports a minimal version of tweaking the class hierarchy. You can use AspectJ to add any interface onto a class or interface, or you can add a class that is a subclass of the same class that tthe target type is.
Example, the following is an error:
aspect AnAspect {
declare parents : AClass extends Foo;
}
class AClass extends Bar { }
class Foo { }
class Bar { }
This is an error because Foo is not in the same class hierarchy as AClass or Bar. However, this small change will make the error go away:
class Foo extends Bar { }
See:
http://www.eclipse.org/aspectj/doc/released/progguide/semantics-declare.html#extension-and-implementation
This is tricky stuff, and can cause some tricky errors if you are not careful.
Intertype declarations in AspectJ are also a bit like multiple inheritance in that they can add extra functionality to classes, but they avoid all of the difficulties and ambiguities associated with multiple inheritance.
Other aspect oriented languages handle the multiple inheritance issue differently.