Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Introductions and multiple inheritance (sort of)



Manuel,

I believe you are working from a false premise. As you correctly observe
AspectJ does not add support for multiple inheritance rather it allows
classes to inherit default implementations of one or more interfaces. These
default implementations are applied through an inter-type declaration on
each interface. This avoids the ambiguities associated with other
approaches because:
1. Any explicit method implementation will be used first
2. If there are multiple interfaces with the same default method
implementation a compiler error is issued

To address your questions:
- You cannot use "super" within an ITD method on an interface because its
superclass is java.lang.Object. The interface can be added to multiple
classes through "declare parents .. implements" so the superclass can only
be determined at runtime. Using a default method implementation to override
an inherited method seems problematic: do you have a use case?
- In ordinary Java if you implement 2 interfaces with the same method they
are merged and you only have one implementation. AspectJ will only allow
you to inherit one default method implementation (as described above). As
far as I know multiple inheritance schemes only allow you to have one
implementation of an inherited method (but knowing which one is usually the
problem). I'm not sure how to support multiple implementations of a method
in a single class. What did you have in mind?

If you read Chapter 8 of "Eclipse AspectJ"
(http://www.awprofessional.com/title/0321245873) you will find a discussion
of this subject.

Cheers

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

Manuel Menezes de Sequeira <Manuel.Sequeira@xxxxxxxx>@eclipse.org on
20/01/2005 14:27:39

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    aspectj-users@xxxxxxxxxxx
cc:
Subject:    [aspectj-users] Introductions and multiple inheritance (sort
       of)


Hi,

AspectJ introduces a limited form of multiple inheritance into the Java
language, using introductions.  Multiple inheritance poses some
interesting problems, such as resolving ambiguities in method calls,
knowing whether attributes inherited from a common base through
different base classes are duplicated or not, etc.  I have made a few
experiments and got to a few troubling conclusions.  One of them is that
when you implement an interface with an introduced method
implementation, you cannot use super within an overriding method (super
refers to the extended class, not the implemented interface).  Another
is that you cannot implement two different interfaces which implement
methods (using introductions) with the same signature (this one is
particularly troubling).  Is there a detailed description of the way
multiple inheritance works in AspectJ?

Thanks in advance,

Manuel
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top