6 Replies Latest reply on May 19, 2016 3:24 PM by chiba

    try ... finally


      The docs for 3.0 still state that try ... finally is not supported. Is this true? I would very much like to use Javassist for a particular application, but being able to use a finally clause is critical.

        • 1. Re: try ... finally

          OK, I'll put finally support in my TODO list.

          • 2. Re: try ... finally

            Finally, finally clauses have been supported. :)

            • 3. Re: try ... finally

              chiba, in what kind of support?

              I've recently started to use javassist. and I found that try..finally is not executed when an exception occured.


              below is my usage:



              String methodBody = "

                 try {


                 } finally {

                     // here is my own logic   #1



              CtMethod methodNew = CtNewMethod.copy(methodOriginal, methodName, ctClass, null);





              for this code, I found that if there is no exception, the code in the finally block will execute.

              if there IS an exception occurs, the finally block won't execute.


              is this expected ? or it is due to my wrong usage or setting?

              my javassist version is:







              • 4. Re: try ... finally

                false alarm!


                it turns out to be the fault of my testing code.

                • 5. Re: try ... finally