Bug 359114

Summary: consider adding a hasDeclaredMethod() pointcut
Product: [Tools] AspectJ Reporter: Carlos Anjos <carlos.anjos>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: carlos.anjos
Version: DEVELOPMENT   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Carlos Anjos CLA 2011-09-27 13:01:37 EDT
The experimental hasmethod() pointcut matches methods that are declared in superclasses.

Having a hasDeclaredMethod() pointcut would allow to provide different implementation for a method without risking conflicts with Inter Type Declarations.

Example:

aspect myITD {
  public void MyHelloInterface.sayHello() {
    System.out.println("hello");
  }

  declare parents: !hasDeclaredMethod(void *.sayHello()) implements MyHelloInterface;
}

This way the ITD would never clash with classes that already have a sayHello().

Sometimes we could achieve this result, by injecting the ITD into the superclass of the class we want to advise, but that is not always possible.