Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Please help us to check if all our public methods call a known method or not, at compile-time

Aimé KASSA wrote:
> We intend to use AspectJ' static crosscutting
> mechanism to to implement behavior similar to the C
> #error preprocessor directive. We're just starting to
> use AspectJ...
>
> How to specify a pointcut allowing us to detect the
> absence of a call to MyClass.mandatoryMethod(..)
> inside all public methods (at compile-time)?

One refactoring is to do the mandatory call in advice
(and optionally skip all the calls from your code
until you find and remove them).

Implementing it with advice :

  before() : within(com.foo..*) && execution(public * *(..)) {
     mandatoryCall();
  }

Skipping any other calls made (if you can't remove them):

  void around(): within(com.foo..*) && !within(Aspect)
        && call(void mandatoryCall()) {
     // no proceed();
  }

As for finding methods that don't call this mandatory method,
you might try another tool like JQuery.

Wes




Back to the top