Community
Participate
Working Groups
The resolution to bug #134425 allows calling super to invoke ITD methods defined on a superclass. However, doing the same for ITD methods defined on an implemented interface is a compile-time error with recent dev builds and 1.5.2. I believe this should be allowed, since super should be unambiguous. However, I can imagine that this could be complicated to implement: public class Base {} public interface If {} public class Derived extends Base implements If { public static void main(String argz[]) { new Derived().handle(); } public void handle() { System.err.println("Before..."); super.handle(); } } public aspect Poke { public void If.handle() { System.err.println("handled"); } } C:\devel\scratch\superInterface>ajc *.aj C:\devel\scratch\superInterface\Derived.aj:8 [error] The method handle() is unde fined for the type Base super.handle(); 1 error
The programming guide hints/says that ITD's on interfaces are implemented only in the topmost classes: "When declaring members on interfaces, the implementation must control both the interface and the top-level implementors of that interface (the classes that implement the interface but do not have a superclass that implements the interface)" So your code would work if Base implemented If, but as-is Poke's ITD handle() is deferring to Derived.handle(). Although the interface is a supertype of the implementing class, it is not a superclass of the implementing class, and thus super won't work. What's the use-case for doing this?