我知道AspectJ可以声明inter-type,但我想声明一个变量内部的TestMain.test方法,因此只有那个方法可以得到它,但所有其他方法都无法获取变量。
public aspect GetParams {
public int TestMain.anInt = 2; // I know this is accessed in the whole scope of a TestMain instance
// How to declare a local variable only for TestMain.test
}
public class TestMain {
public void test(int a)
{
System.out.println(anInt);
}
public void test2() {
// cannot accessed here
}
}
---------------更新------------------
我描述了我想要的东西。
该场景是针对Jersey API的一种方法,我希望在方法中获得一个映射器,其中包含所有参数和API所需的值。因此,我希望自动完成此工作的方法有一个注释。