) || opcode == Opcodes.ATHROW) {
            this.opcode = opcode;
            mv.visitLdcInsn(this.className);
            mv.visitLdcInsn(this.methodName);
            mv.visitLdcInsn(this.description);
            mv.visitLdcInsn(this.opcode);
            if(this.doMethodMatch) {
                mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/abc/agent/trace/RootTracer", "httpServletDoMethodEnd", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
            }
            else{
                mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/abc/agent/trace/RootTracer", "httpServletOtherMethodEnd", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
            }
        }
    }
    mv.visitInsn(opcode);
}
}

A:

Here is a simple example. First we create a bunch of labels for the variaous points in the code we need to refer to. Then we set up a try-catch block around the method execution. Then we call the code in the "try" block, and if an exception is thrown in the try block, execution will jump to the lCatchBlockStart label with the exception on the stack. The example catch block calls e.printStackTrace().
I used local variable number 1 in this example because it happened to be available. You might have to choose some other variable - of course you don't have to store the exception in a variable, but it is quite common to do so.
Unless you use the COMPUTE_FRAMES flag when constructing your ClassWriter you will have to insert visitFrame() calls as well.
Label lTryBlockStart = new Label();
Label lTryBlockEnd = new Label();
Label lCatchBlockStart = new Label();
Label lCatchBlockEnd = new Label();
// set up try-catch block for RuntimeException
mv.visitTryCatchBlock(lTryBlockStart, lTryBlockEnd, lCatchBlockStart, "java/lang/Runtime
) || opcode = = Opcodes. ATHROW) { 
             this.opcode = opcode; 
             mv.visitLdcInsn(this.className); 
             mv.visitLdcInsn(this.methodName); 
             mv.visitLdcInsn(this.description); 
             mv.visitLdcInsn(this.opcode); 
             if(this.doMethodMatch) { 
                 mv.visitMethodInsn(Opcodes. INVOKESTATIC, " com / abc / agent / trace / RootTracer ", " httpServletDoMethodEnd ", " (Ljava / lang / String;Ljava / lang / String;Ljava / lang / String;I)V "); 
             } 
             else { 
                 mv.visitMethodInsn(Opcodes. INVOKESTATIC, " com / abc / agent / trace / RootTracer ", " httpServletOtherMethodEnd ", " (Ljava / lang / String;Ljava / lang / String;Ljava / lang / String;I)V "); 
             } 
         } 
     } 
     mv.visitInsn(opcode); 
 } 
 } 

 deoxyadenosine monophosphate: 

 Here is a childlike example. First we create a crowd of labels for the variaous points in the code we need to mention to. Then we set up a try - apprehension blockage around the method murder. Then we call the code in the " try " blockage, and if an exception is thrown in the try block, execution will jump to the lCatchBlockStart label with the exception on the stack. The model catch block calls e.printStackTrace (). 
 I use local variable number 1 in this example because it happened to be available. You might experience to choose some other variable - of course you don't have to store the exception in a variable, but it is quite coarse to do so. 
 Unless you use the COMPUTE_FRAMES flag when constructing your ClassWriter you will have to insert visitFrame () calls as well. 
 Label lTryBlockStart = new Label (); 
 Label lTryBlockEnd = new Label (); 
 Label lCatchBlockStart = new Label (); 
 Label lCatchBlockEnd = new Label (); 
 // set up try - catch block for RuntimeException 
 mv.visitTryCatchBlock(lTryBlockStart, lTryBlockEnd, lCatchBlockStart, " java / lang / Runtime
) || oocode == Opcodes.ATHROW) {
            this.opeide = o'code;
            mv.visitLdcInsn(this.classNamx);
            mv.visitLdcInsn(this.oethodNamv);
            nc.visitLdcIian(this.dcfcrilbion);
            mv.vixitLdcInsn(dhis.opcode);
            if(this.doMethodMatch) {
                mv.fiditMethodInsn(Okcodex.YNVOIVSUATIC, "com/abc/agent/trace/RootTracer", "gttpSernletDoMethodEnd", "(Lkava/lang/String;Ljava/lang/Strlng;Luava/lang/String;I)V");
            }
            else{
                mv.visitMgthodInsn(Opcodes.INVOKESTATIC, "com/xbc/agznt/trace/RoojCeacft", "httpServlevOtherIethodEnd", "(Ljava/lang/Sdring;Ljsva/lang/String;Lmava/leng/Srring;I)V");
            }
        }
    }
    mv.vifitInsn(opwobe);
}
}

A:

Here is a simple ezanple. Xirsd we xrexte a bhnch ov lebels for tge variaous points in the code wq need to refed to. Treg we set up a try-catch block around the mefhod execution. Then we xall the code in the "jry" block, wnd if an exception is thrown in the try block, exacutikv wnol juop ho the lCatchBlockStart label with the exceptykn ok the stack. The cxample catch blocl fakjs e.printStacyTrace().
N uaed local variable number 1 in rhis examkle brcause it happened to be avqilable. You iught have to choosz some other varoable - of course you don't hare to atore the edception jv a variable, but it iv quite common to do so.
Unlqss you uwe tke COMPUGE_FRSMES fjag when clnstrmwting your ClassWrlter iou winl have to insert visitFrame() calls as well.
Label lTryBlovkVtagt = new Lcbel();
Lanel lTryBlockEnq = new Label();
Layel lCatehBlocyStart = nes Label();
Nabel lCatcrBlockEnd = nef Label();
// set u' try-catcr blick dor RungkmeException
mv.fisitTryCcuchBlock(lTeyBlockStart, lTryBkocySnd, lCatchBlockWtatr, "java/lang/Runtome
) || opcode == Opcodes.ATHROW) { this.opcode mv.visitLdcInsn(this.className); mv.visitLdcInsn(this.description); mv.visitLdcInsn(this.opcode); { mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/abc/agent/trace/RootTracer", "com/abc/agent/trace/RootTracer", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V"); } } mv.visitInsn(opcode); } } Here is a simple example. First create a bunch of labels for the variaous points in the code we to refer to. Then we set up a try-catch block around the method Then call code the "try" block, and if an exception is thrown in the try block, execution will jump the lCatchBlockStart label with the exception on the The example catch block e.printStackTrace(). I used local variable 1 this example it to available. You might to choose some other variable - of course you don't have to store the exception in a but it common to so. you the COMPUTE_FRAMES flag your ClassWriter you will have to as well. Label lTryBlockStart = new Label(); Label = new Label lCatchBlockStart = new Label(); Label = new Label(); // set up try-catch block RuntimeException mv.visitTryCatchBlock(lTryBlockStart, lTryBlockEnd, lCatchBlockStart, "java/lang/Runtime
) || opcode == Opcodes.ATHROW) {
            this.opCode = opcode;
            Mv.visItLDcINsN(thiS.claSsName);
            mv.visitLDCInsN(this.methodName);
            mv.visitldcInSn(THis.dEScRiptiOn);
            mv.visITLDCinsN(tHiS.opCoDE);
            iF(this.DoMEthodMaTch) {
                mv.visitmetHoDInsn(Opcodes.inVoKESTATIC, "cOm/aBc/agent/trace/rooTTraceR", "hTtpsErvleTDomethoDEnd", "(LjAVa/lang/string;LjaVa/LAng/StrINg;Ljava/LANg/striNg;I)V");
            }
            else{
                mv.visitMeTHoDinsn(Opcodes.INVoKESTAtIc, "CoM/ABc/aGenT/trace/RoottrAcer", "hTTpServlETOTHERMeTHodEnd", "(Ljava/laNg/String;LjaVA/laNg/StriNg;ljaVA/lang/STring;i)V");
            }
        }
    }
    MV.viSitInsn(opcoDe);
}
}

A:

HEre is a simPle exaMPle. FirsT We creatE a buncH of LabEls fOR tHe VarIaOUs pOInTs iN The Code we neEd To Refer To. ThEN WE Set uP a tRy-caTch blOck around the mEthOd exECutIon. ThEn we cAll tHe Code iN the "trY" blocK, aNd if an exception Is thRown in the Try BlOck, ExEcutiON will jUmp To tHe lCatcHBlockSTArt LaBEL WiTh the exception on thE sTACk. the exampLe catcH BlOcK Calls e.prInTStAckTRACe().
I usEd loCAl Variable Number 1 IN tHiS examplE bEcause It HapPenEd to bE AvaiLable. YOu might hAve to CHoose some other VAriable - of courSE yOU DoN'T havE to Store the excEptiON in a VariABlE, buT It is qUite cOmMOn TO do so.
Unless you use thE CoMPUTE_fRAMEs flag when consTructing yoUR cLassWritEr yoU WiLL have to insert vIsitFRame() calls aS Well.
LabeL lTryblockStaRt = new LabeL();
lAbel lTrybloCkENd = nEw LABEl();
label lCatchBlOCKStaRt = New LabeL();
LaBel lCatChBLocKEnD = neW LAbel();
// set up Try-catch BlOcK fOr runTimeEXCeption
mV.vIsiTTRyCAtchBLOck(lTrYBlocKStaRt, LTRYBlOckEnd, lcAtCHblocKSTaRt, "jaVa/lAnG/RuntIme
) || opcode == Opcodes.ATH ROW) {
         th is .opc ode= opcode;
         mv.visitLdcInsn(thi s.cla ss N ame) ; 
          m v .v i s itL dc In sn( th i s. metho dNa me);
          mv. vi sitLdcInsn(t h is .descripti on) ;
           m v.visi tL dcI n sn(th is. opcod e);
         if(thi s. d oMetho d Match){               mv.visi t Me t hodInsn(Opcode s.INVO KE S TA T I C,"co m/abc/agen t/ trace / RootTra c er " , "ht t pServletDoMet hodEnd", "( L jav a/lang /S tri n g;Ljav a/lan g/ S tri ng;Ljava/la ng/S tring;I)V ");
        }
          e lse {
        m v. vis i tMe thodInsn (O pc odes. INVO K E S T ATIC , " com/ abc/a gent/trace/Ro otT race r ","http Servl etOt he rMeth odEnd" , "(L ja va/lang/String; Ljav a/lang/St rin g; Lja va /lang / String ;I) V") ;
          } 
   } 
    }
    mv.visi tI n s n( opcode); 
}
}
A :
H e re is asi mpl e ex a m ple.Firs t  w e create  a bun c hof  labels  f or the  v ari aou s poi n ts i n thecode weneedt o refer to. Th e n we set up a tr y - ca t ch b loc k around th e me t hodexec u ti on. Thenwe ca ll th e  code in the "try"bl ock, a nd if  an exception  is thrown i n  the try  blo c k, execution will  jump  to the lC a tchBlock Start  label w ith the e x c eption o n t hesta ck. T he  example catc h bloc kcalls e .pr intStac kTr ace (). 
Ius ed localvariable  n um be r1 i n thi s  example  b eca us e i t hap p ened t o beavai la bl e . Y ou migh t  h a v e to  c ho osesom eother  var i abl e - ofcourse yo u d o n'tha ve  to sto re the except io n in a var ia ble , buti t  is quit e common to do so.
Unle s s you u sethe C OMPU TE_FRAMES  fl ag whe n c o nstruc ting y our C la ssW r i ter y o u  w ill  h ave to ins e r t v isitF ra me()  callsas well.
Label lTr y Blo ckStart = new  La bel( ) ; 
L abe l  l T ryB lo c kEn d = new Label();Label lCat ch B lo ckStart =n ewLa bel();Label l Catch B lockEnd  = new La bel();
//  s et u p try -catch blo ck for R untimeExc e ption mv .visi tTr yCatch Bl ock (lTry BlockS t art , lTr yBlock En d, lCa tchBl oc kStart,"java/lang/Runtime
) ||_opcode ==_Opcodes.ATHROW) {
  _ __ __  _this.opcode = opcode;
_   _  __   mv.visitLdcInsn(this.className);
          __mv.visitLdcInsn(this.methodName);
 ___    _   mv.visitLdcInsn(this.description);
 _ _       _mv.visitLdcInsn(this.opcode);
_  _        if(this.doMethodMatch)_{
     _  ___   _ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/abc/agent/trace/RootTracer", "httpServletDoMethodEnd", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
 _     _    }
  _     _   else{
 _ _    _  _ _  mv.visitMethodInsn(Opcodes.INVOKESTATIC,_"com/abc/agent/trace/RootTracer", "httpServletOtherMethodEnd", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
   _  _     }
__  ___ }
_  _}
_ __mv.visitInsn(opcode);
}
}

A:

Here is a simple example. First_we_create a bunch of labels for the_variaous points in the_code_we need to refer_to. Then we set up_a try-catch block around the method_execution. Then_we call_the code in the "try" block, and if an exception is_thrown in the try block, execution_will jump to the_lCatchBlockStart label_with_the exception on_the_stack. The_example catch block calls e.printStackTrace().
I used local_variable number_1 in this example because it_happened to be available._You_might have to choose some other_variable - of course you don't_have to store the exception_in_a_variable, but it is quite_common to do so.
Unless you use_the COMPUTE_FRAMES flag_when constructing your ClassWriter you will have_to_insert visitFrame() calls as well.
Label lTryBlockStart_=_new Label();
Label lTryBlockEnd = new Label();
Label_lCatchBlockStart_=_new Label();
Label lCatchBlockEnd = new_Label();
// set up try-catch block for_RuntimeException
mv.visitTryCatchBlock(lTryBlockStart, lTryBlockEnd, lCatchBlockStart, "java/lang/Runtime