Hi All,
just wanted to clarify something regarding local variables..
I am instrumenting a method with a call to method at entry and exit
of method using try-finally blocks..so i need to create some local
variables dynamically...
So I need to pass an index to them, so I tried to get the latest
index and increment it in the following manner
// code
int i = methodgen.getLocalVariables().length
my_lv1 = i+1;
my_lv2 = i+2;
my_lv = i+3;
// code
and I used to store using il.append ( new ASTORE ( my_lv2 ) );
I encountered a problem with this, i.e. the variable i returned
22,
where as the max index is 7.. So there was overlap in the local
vars and my class file got corrupted
I just wanted to know..why is it like that.. Doesn't each local
variable have unique index?
Isnt the length (i that is returned) mean the no of local
variables in the corresponding method?
However now I tried using
// code
int max_index = 0;
LocalVariableGen[] lv1 = mgen.getLocalVariables();
for(int i = 0; i< lv1.length; i++){
if(lv1[i].getIndex() > max_index)
max_index = lv1[i].getIndex();
}
my_lv1 = i+1;
my_lv2 = i+2;
my_lv = i+3;
// code
and it works fine..
but I just wanted to clarify it.
Please help me in this regard.
Thank you
Reddy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]