Bug 156149 - Problem Calling Super for ITD defined on Interface
Summary: Problem Calling Super for ITD defined on Interface
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-05 02:22 EDT by Ron Bodkin CLA
Modified: 2007-02-16 04:44 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2006-09-05 02:22:28 EDT
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
Comment 1 Wes Isberg CLA 2007-02-16 04:44:57 EST
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?