Problem with instrumentation in constructors
"Koduru, Rajendra Kumar Reddy" <[email protected]>
| Newsgroups | gmane.comp.jakarta.bcel.user |
|---|---|
| Message-ID | <[email protected]> |
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