I know AspectJ can declare inter-type, but I want to declare a variable inner TestMain.test method, thus only that method can get it but all of other methods can't get the variable.
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
}
}
--------------- Update ------------------
I describe what I want.
The scenario is in a method for Jersey API, I wants to get a mapper in the method that contains all but only the parameters and the values the API needs. Thus I hope there's is an annotation on the method which does this job automatically.