-
1. Re: try ... finally
chiba Oct 8, 2004 11:58 AM (in response to hlship)OK, I'll put finally support in my TODO list.
-
2. Re: try ... finally
chiba Nov 4, 2004 11:32 AM (in response to hlship)Finally, finally clauses have been supported. :)
-
3. Re: try ... finally
alexandnpu May 19, 2016 12:35 AM (in response to chiba)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 {
%s($$);
} finally {
// here is my own logic #1
}
";
CtMethod methodNew = CtNewMethod.copy(methodOriginal, methodName, ctClass, null);
methodNew.setBody(methodBody);
ctClass.addMethod(methodNew);
====================================================================
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:
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
-
4. Re: try ... finally
alexandnpu May 19, 2016 2:15 AM (in response to alexandnpu)false alarm!
it turns out to be the fault of my testing code.
-