Search code examples
aopaspectj

How to pick out calls to methods with default visibility?


It is possible to pick out calls to methods with any of the three visibility-modifiers, e.g.

call(public * TestClass.*(..));

but not for those with default visibility. I can think of this way around it:

    pointcut bla():
        call(!public * TestClass.*(..))
        && call(!protected * TestClass.*(..))
        && call(!private * TestClass.*(..));

Still, I was wondering if there is no shorter way of doing it?


Solution

  • // Intercept caller
    pointcut packageVisibleMethodCall() :
        call(!private !public !protected * *(..));
    
    // Intercept callee
    pointcut packageVisibleMethodExecution() :
        execution(!private !public !protected * *(..));