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

sanjayvacharya do-not-reply at jboss.com
Sun Sep 14 11:53:01 EDT 2008


I can accomplish the above by doing an :

 
  | ctMethod.insertAfter("System.out.println(\"After Foo\"", true).
  | 

and then an:
ctMethod.insertBefore("System.out.println(\"Before Foo\"");

However I cannot seem to access a local variable in the finally for example:

  | long start = System.currrentTimeMillis();
  | System.out.println("Before Foo");
  | try {
  |   System.out.println("Foo");
  | } finally {
  |    long end = System.currentTimeMillis();
  |    System.out.println("Foo too:" + (end - start));    
  | }
  | 

The problem is when I am altering the method for the finally, I cannot access the start variable I introduced.

Any tips would be welcomed.

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

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



More information about the jboss-user mailing list