Bug 467799 - Inner aspect cannot add an inter-type method if there is a 'private-final' method with the same signature in the parent class.
Summary: Inner aspect cannot add an inter-type method if there is a 'private-final' me...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-21 01:55 EDT by Jiyong Park CLA
Modified: 2015-05-21 02:01 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiyong Park CLA 2015-05-21 01:55:05 EDT
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() { }
                   ^^