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/[email protected]/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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to