Bug 359114 - consider adding a hasDeclaredMethod() pointcut
Summary: consider adding a hasDeclaredMethod() pointcut
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-27 13:01 EDT by Carlos Anjos CLA
Modified: 2011-09-27 13:02 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 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.