Bug 50195 - overriding introduced methods with default access fails
Summary: overriding introduced methods with default access fails
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords: info
Depends on:
Blocks:
 
Reported: 2004-01-19 04:46 EST by Wes Isberg CLA
Modified: 2004-01-23 21:57 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 Wes Isberg CLA 2004-01-19 04:46:32 EST
A surprising corner case:  overriding an introduced method with default access
in a subclass doesn't work.  It does work for regular Java and for public
methods.  Below is a short sample; I checked in no test case, since this might
be a known limitation to be documented ("info"?).

public class IntertypeDeclarationConflict {
    public static void main(String[] args) {
        new C().run();
        new CC().run();
    }
}
class C {
    void run() {}
}

class CC extends C {
    String getName() {
        return "CC";
    }
}
aspect A {
    String C.getName() { 
        return "A";
    }
}
//aspect B {
//    declare precedence : B, A;
//    String C.getName() { 
//        return "B";
//    }
//}
aspect D {
    before(C c) : execution(void run()) && target(c) {
        System.out.println(c + "-" + c.getName() + " " + thisJoinPointStaticPart);
    }
}
Comment 1 Jim Hugunin CLA 2004-01-23 21:57:11 EST
This is a known limitation (known to me at least ;-)  I'm marking as info and 
closing.  Only publically introduced members can be overriden by standard Java 
code.  A corollary of this is that only publically introduced members are 
generated with non-mangled names and are effectively visible to pure Java 
compilers.

In a future release we could relax this restriction for the case where the 
target class and the aspect are both in the same package and the target is not 
an interface.  Personally I prefer the simpler rule that clearly separates 
public introductions from all others.