jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koduru, Rajendra Kumar Reddy" <rajendra.kumar.reddy.kod...@sap.com>
Subject Query regarding index of local variables
Date Tue, 08 Feb 2005 12:42:39 GMT
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: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Mime
View raw message