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 Problem when creating a local variable in a method
Date Fri, 04 Feb 2005 10:19:52 GMT

Hi All,
	I am new to BCEL. Just started using it. I had a problem with
local variable insertion to a method dynamically. 
	I tried to find in internet resoruces , but could not, could you
please help me in this regard.

	I am trying to open the modified class with decompiler, a dialog
appears, when decompiling saying 
			The instruction at "0x..." reference memory at
"...". The memory could not be read.

	however a jad is created, in which all the methods starting from
the modified method no more appear in the class file, i.e methods are
gettign 	corrupted.

	Please have a look at the following code[1] and please correct

	should I do some updations to local variable table after
insertion of a local variable or is it automatically updated ????

	please help me in this regard.

Thank you 

	class A{

		public Method instr( JavaClass javaClass, 
                                    Method method, 
						ConstantPoolGen poolGen,

factory ) {

		MethodGen mgen = new MethodGen(method,
javaClass.getClassName(), poolGen);

		InstructionList ilist = mgen.getInstructionList();
		InstructionList ilist_start = new InstructionList();
		insertStaticCallAtEntry(mgen, poolGen, factory,
ilist_start, methodName);

		InstructionHandle ihss = ilist.insert( ihandle_start,
	      ilist.redirectBranches( ihandle_start, ihss); 
		return mgen.getMethod();

		private void insertStaticCallAtEntry( MethodGen mgen
                                         , ConstantPoolGen poolGen 
                                         , InstructionFactory factory
                                         , InstructionList ilist_start 
                                         , String method_call) {
method_call, Type.VOID,
                                            new Type[]{},

      	  LocalVariableGen localVar= mgen.addLocalVariable("obj",new
ObjectType("java.lang.Object"), null, null);
	        int obj = localVar.getIndex();
      	  Tracer.trace("index is "+ obj);

	        localVar.setStart(ilist_start.append(new ASTORE(obj)));




To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org

View raw message