[
https://issues.apache.org/jira/browse/GROOVY-8085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15875245#comment-15875245
]
Daniel Sun commented on GROOVY-8085:
------------------------------------
Since L1 has not been covered by exception table, so exception occurred in the
the normal excution flow can not be handled, i.e. no error in the inner try
block but failed in the finally block.
I tried to add 99 / 0 to the inner try block to make it fail on purpose, then
the exception can be handled properly. I guess some bug exists in
StatementWriter(https://github.com/apache/groovy/blob/master/src/main/org/codehaus/groovy/classgen/asm/StatementWriter.java#L308),
the range of try block seems not be recorded correctly...
{code}
public static void main(String[] args) {
try {
try {
System.out.println("try!!!");
99 / 0
} finally {
99 / 0
}
} catch (Exception e) {
System.out.println("catch!!!");
}
}
{code}
> Exception in "finally" not caught by outer "try"
> ------------------------------------------------
>
> Key: GROOVY-8085
> URL: https://issues.apache.org/jira/browse/GROOVY-8085
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.8
> Environment: linux
> Reporter: Craig Silverstein
>
> I would expect the following code to print `caughtt`:
> ```
> groovy -e 'try { try { true; } finally { 1 / 0 } } catch (e) { println
> "caughtt" }'
> ```
> But instead, it prints:
> ```
> Caught: java.lang.ArithmeticException: Division by zero
> java.lang.ArithmeticException: Division by zero
> at script_from_command_line.run(script_from_command_line:1)
> ```
> Why is the exception, thrown by the `finally`, not being caught by the outer
> try/catch?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)