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 RE: Problem with instrumentation in constructors
Date Thu, 17 Feb 2005 13:30:48 GMT
Hi Andrew,
	
	Yep, I have seen your objections to the instrumentaion procedure
of constructor that was mentioned by you in the corresponding thread..

	The approach you suggested worked, but with a small change... 
	In the getIListSuper() method, instead of using superList as
mentioned 
	
	superList = iList.copy(); I used
	iList itself in this method..

	the former was returning instruction handle -1 and the later +1,
with a basic super() being first call.

	and was not able to insert with former..so choosed the
later..however am not sure of reason for this..could you please clarify
me, why is this happening..is this due to copy()
method???????????????????????

public InstructionHandle getIListSuper(InstructionList iList){
     
     int invkSpec = 0;
 
     InstructionHandle seperator = null;
    
     InstructionList superList = iList.copy(); // deep copy
[COMMENTED OUT IN CURRENT METHOD]
     
     for ( Iterator i = superList.iterator (); i.hasNext (); ) {
[ USED iList in place of superList in this statement]
       seperator = ( InstructionHandle ) i.next ();
 
       if(seperator.getInstruction() instanceof NEW )
           invkSpec++;
 
       if(seperator.getInstruction() instanceof INVOKESPECIAL )
         invkSpec--;
 
       if(invkSpec < 0 )
         break;
     }
     
     if(invkSpec < 0) {
     return seperator
     }
   
 	  return null;
     }


Thank you
Reddy
 











>-----Original Message-----
>From: Andrew Huntwork [mailto:ash@huntwork.net] 
>Sent: Mittwoch, 16. Februar 2005 18:03
>To: BCEL Users List
>Subject: Re: Problem with instrumentation in constructors
>
>
>First, note my objections to this method given in the thread you 
>reference below.
>
>It looks like you're saying below that your current problem is that 
>you're getting TargetLostExceptions.  I would propose a slightly 
>different idea for getIListSuper that would possibly solve several 
>problems:
>
>InstructionHandle getIListSuper(InstructionList il) {
>  //do your NEW/INVOKESPECIAL counting here to find the super() call
>  return separator;
>}
>
>now change insertTryFinally to have this signature:
>void insertTryFinally(InstructionList il,InstructionHandle ih) and
>pass it separator.  make the beginning of the try / finally be 
>separator.  remove this block, since it's no longer necessary:
>
>
> > 	if(superList != null){
> >         iList.insert ( iList.getStart (), superList );
> >         }
>
>i wonder how that will work.
>
>Koduru, Rajendra Kumar Reddy wrote:
>> 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
>> 
>> 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
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