1515 ******************************************************************************/
1616package com .ibm .javametrics .instrument ;
1717
18+ import org .objectweb .asm .Label ;
1819import org .objectweb .asm .MethodVisitor ;
1920import org .objectweb .asm .Type ;
2021import org .objectweb .asm .commons .Method ;
@@ -29,6 +30,7 @@ public class ServletCallBackAdapter extends BaseAdviceAdapter {
2930 private static final String SERVLET_CALLBACK_BEFORE = "void before(java.lang.Object, java.lang.Object)" ;
3031 private static final String SERVLET_CALLBACK_AFTER = "void after(java.lang.Object, java.lang.Object)" ;
3132
33+
3234 protected ServletCallBackAdapter (String className , MethodVisitor mv , int access , String name , String desc ) {
3335 super (className , mv , access , name , desc );
3436 if (Agent .debug ) {
@@ -52,8 +54,20 @@ protected void onMethodExit(int opcode) {
5254 * @param method
5355 */
5456 private void injectServletCallback (String method ) {
57+ Label tryStart = new Label ();
58+ Label tryEnd = new Label ();
59+ Label catchStart = new Label ();
60+ Label catchEnd = new Label ();
61+
62+ visitTryCatchBlock (tryStart , tryEnd , catchStart , "java/lang/NoClassDefFoundError" );
63+ visitLabel (tryStart );
5564 loadArgs ();
5665 invokeStatic (Type .getType (SERVLET_CALLBACK_TYPE ), Method .getMethod (method ));
66+ visitLabel (tryEnd );
67+ visitJumpInsn (GOTO , catchEnd );
68+ visitLabel (catchStart );
69+ pop ();
70+ visitLabel (catchEnd );
5771 }
5872
5973}
0 commit comments