现有表达式应切入所有参数为android.view.View 的lambda方法,事实也确实如此
//切点
@Around("execution(void *.lambda$*$*(android.view.View))")
public void onLambdaClick(ProceedingJoinPoint joinPoint) throws Throwable {
Log.e(TAG, "lambda click拦截 ");
// if (!NoDoubleClickUtils.isDoubleClick()) {
// joinPoint.proceed();
// }
}
// 实现代码
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.bt1).setOnClickListener(o -> {
Log.e("aspect", "执行");
});
findViewById(R.id.bt).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new Test().set(j -> {
});
}
});
}
}
```java
// 自定义测试切点
public class Test {
public interface IFunctionTest {
void print(View x);
}
public void set(Test.IFunctionTest iFunctionTest) {
Log.e("TAG", "set: ");
}
}
// 织入后代码
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.example.test1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.runtime.reflect.Factory;
public class MainActivity extends Activity {
public MainActivity() {
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(2131427356);
this.findViewById(2131230808).setOnClickListener((o) -> {
JoinPoint var2 = Factory.makeJP(ajc$tjp_0, (Object)null, (Object)null, o);
lambda$onCreate$0_aroundBody1$advice(o, var2, OnClick.aspectOf(), (ProceedingJoinPoint)var2);
});
this.findViewById(2131230807).setOnClickListener(new OnClickListener() {
public void onClick(View view) {
(new Test()).set((j) -> {
JoinPoint var2 = Factory.makeJP(ajc$tjp_0, (Object)null, (Object)null, j);
lambda$onClick$0_aroundBody1$advice(j, var2, OnClick.aspectOf(), (ProceedingJoinPoint)var2);
});
}
static {
ajc$preClinit();
}
});
}
static {
ajc$preClinit();
}
}
new Test().set()方法确实被识别并织入成功,但点击织入代码没有生效。求解答