[jboss-user] [Javassist user questions] - Re: try finally around a method

sanjayvacharya do-not-reply at jboss.com
Sun Sep 14 12:43:29 EDT 2008


I thing I figured it out. I did the following:

  | final String beforeMethod = "{long startTime = System.currentTimeMillis(); System.out.println(\"Before Foo\");";
  | final String afterMethod = "finally {long diff = System.currentTimeMillis() - startTime; System.out.println(\"Foo completed in:\" + diff);}}";
  | 
  | mold.instrument(
  |       new ExprEditor() {
  |           public void edit(MethodCall m)
  |                         throws CannotCompileException
  |           {       
  |             m.replace(beforeMethod + " try {$_ = $proceed($$); } " + afterMethod);
  |           }
  |       });
  | 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4176377#4176377

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4176377



More information about the jboss-user mailing list