Hi,
        I have a query regarding the instrumentation of the
constructor. I have read all the archived mail in this
regard, but none of them served useful. I have the
same requirement i.e. put a method call at each method
start and method end. Have already put a try catch for
that. Now the task is to skip super() call before I
put my method call in the constructor.
        
        I have a code that works for 99% of the cases. 
        
        for(int j = 1; j < ihs.length; j++)
        {
                if(ihs[j].getInstruction() instanceof INVOKESPECIAL)
                {
                        il.append(ihs[j], instrumentedPatchList);
                        break;
                }
        }
        
        It works for 
        
        1)public ABCD(XYZ obj)
        {
                super(obj);
        }
        
        Now a more complicated case
        
        2)public RuleTree(int type, AppCodeAnalyzerMainPanel
mainPanel)
        {
                super(new DefaultTreeModel(new RuleNode("Rules")));
                method1();
                method2();
        }
        
        The above code fails because the Special Instruction
is not at first position. Hence A refined approach
will be to get the first instruction handle of the
second line in the constructor (first instruction
handle for method1()). Now I scan all the instructions
of the first line (super(new DefaultTreeModel(new
RuleNode("Rules")))). If there is any INVOKESPECIAL in
this list I put my code at the end of first line. This
thing works fine.
        
        A bit more complex case
        
        3)private XYZHandler(EventHandler commandHandler)
        {
                super(
                        ABCD.getInstance(),
                        Helper.getInstance(),
                        commandHandler,
                        100);
                method1();
        }
        
        Now the above mentioned approach doesn't work and I
end up putting my method call before super() and get
VerifyError. Has anyone (especially the ones who have
posted those questions on constructor instrumentation
previously) been able to build a fullproof code?
        
Thanks,
        Nikhil Khedkar

__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

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

Reply via email to