gpt4 book ai didi

java - spectj 将对象获取到切入点内

转载 作者:行者123 更新时间:2023-12-01 04:54:03 25 4
gpt4 key购买 nike

我有以下类(class):

package Test;
public class A
{
private B b = new B()
{
@Override
public boolean someFunc() {return false;}
}
}

捕获 someFunc 执行并同时获取外部类 A 的引用的 AspectJ 切入点是什么?

我尝试过:

pointcut captureExec(): within(Test.A) && execution(boolean Test.B+.someFunc());
before(): captureExec()
{
//here thisJoinPount.getTarget() returns object to class B,
//but I need reference object to the outer class A
}

谢谢

最佳答案

应该是这样的:

pointcut captureExec(Test.A a): within(a) && execution(boolean Test.B+.someFunc());
before(Test.A a): captureExec(a)
{
if(a==blah) ...
}

没试过

关于java - spectj 将对象获取到切入点内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14471183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com