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 with instrumentation in constructors
Date Tue, 15 Feb 2005 15:25:01 GMT
Hi All, 
	
	problem with instrucion list seperation.

	I am trying to instrument my constructor as mentioned in
http://www.mail-archive.com/bcel-user@jakarta.apache.org/msg00475.html

	could you please let me know, where i am going wrong...
	
	instrMethod() {

	 InstructionList iList = mgen.getInstructionList ();
// I am getting my instruction list


	/* if init, I want to seperate this list into two instruction
lists, one containing 
	until super calls (let us say super list)and other containing
the iList,without the instructions till super calls
	*/

	  if ( mgen.getName().equals ( "<init>" ) ){

        superList = getIListSuper(iList);

      }

	// inserting try finally around the iList
	insertTryFinally (iList)
	
	if(superList != null){
        iList.insert ( iList.getStart (), superList );
        } 


	return mgen.getMethod ();
	}


	public InstructionList getIListSuper(InstructionList iList){
    
    int invkSpec = 0;

    InstructionHandle seperator = null;
   
    InstructionList superList = iList.copy(); // deep copy
    
    for ( Iterator i = superList.iterator (); i.hasNext (); ) {
      seperator = ( InstructionHandle ) i.next ();

      if(seperator.getInstruction() instanceof NEW )
          invkSpec++;

      if(seperator.getInstruction() instanceof INVOKESPECIAL )
        invkSpec--;

      if(invkSpec < 0 )
        break;
    }
    
    if(invkSpec < 0) {
    try {
      superList.delete(seperator.getNext(),iList.getEnd()); 	// i
collect here the instruction list till the seperator
	iList.delete(iList.getStart(), seperator);
// the iList that should be instrumented. // throwing target lost
exception

    } catch ( TargetLostException e ) {				
     e.printStackTrace();
    }
 
    return superList;
    }
  
	  return null;
    }



	The problem could be said as seperating an isntruction list into
two instruction lists based on InstructionHandle
	i.e, based on seperator (InstructionHandle), I want to divide
the incoming instructionList into two parts (one list till super call
and other staring
After super() until end)


	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