Community
Participate
Working Groups
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); } }
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.