Community
Participate
Working Groups
Inter-type declaration does not work when the following conditions are ALL met: 1) an aspect is declared inside a class. 2) the aspect tries to add a method into its enclosing class. 3) the enclosing class is extending some other class. 4) the parent class has a method whose signature is same as the inter-type method to be added. 5) the method in the parent class has 'private final' attribute. The problem does not happen when the aspect is not declared inside a class or the method in the parent is declared as 'private', not 'private final'. It seems that the AspectJ compiler prohibits declaring a method when it finds a final method with same signature in parent classes *regardless* of the method's access modifier. When the final method is declared as 'private', the 'final' keyword should not prevent declaring a method with the same signature. Example: public class Parent { private final void foo() { } // method with private final private void foo2() { } // method with just private } class Child extends Parent { static aspect MethodWithSameName { private void Child.foo() { } // compile error private void Child.foo2() { } // ok } } Result: Parent.java:9 [error] can't override final void Parent.foo() private void Child.foo() { } ^^