Community
Participate
Working Groups
suppose pointcut: this(classpath.to.T1) && call(* classpath.to.T2.get*(..)) following codes in T1 Class work: T2 t2=new T2(); t2.getSomething(); // this line is advised but following code in T1 Class don't work: someT1Function(t2::getSomething) //this method reference is not advised
A method reference is not a method call though is it? So I wouldn't expect that to match. It is just a reference to a method that is being passed around. Whatever code you pass it to, if you make a call through its receiving functional interface parameter, you could catch that call: public class YY { public static void main(String[] args) { new YY().run(YY::m); } public void run(SomeFunctionalInterface sfi) { sfi.foo(); } public static void m() { } } interface SomeFunctionalInterface { void foo(); } aspect X { before(): call(* foo(..)) { System.out.println("Called!"); } } Here the advice catches the call to foo() made in the run() method, but we can't currently tell it is being satisfied by a method called 'm' that was passed in by reference.