[ 
https://issues.apache.org/jira/browse/GROOVY-8085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15872941#comment-15872941
 ] 

Daniel Sun commented on GROOVY-8085:
------------------------------------

Jochen, here is the result of java compilation. Only two exception table to 
handle exceptions:
{code}
    TRYCATCHBLOCK L0 L1 L2 null
    TRYCATCHBLOCK L0 L3 L4 java/lang/Exception
{code}

{code}
    // Java code
    public static void main(String[] args) {
        try {
            try {
                System.out.println("try!!!");
            } finally {
                System.out.println(99 / 0);
            }
        } catch (Exception e) {
            System.out.println("catch!!!");
        }
    }
{code}

{code}
    TRYCATCHBLOCK L0 L1 L2 null
    TRYCATCHBLOCK L0 L3 L4 java/lang/Exception
   L0
    LINENUMBER 10 L0
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    LDC "try!!!"
    INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
   L1
    LINENUMBER 12 L1
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    BIPUSH 99
    ICONST_0
    IDIV
    INVOKEVIRTUAL java/io/PrintStream.println (I)V
   L5
    LINENUMBER 13 L5
    GOTO L3
   L2
    LINENUMBER 12 L2
   FRAME SAME1 java/lang/Throwable
    ASTORE 1
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    BIPUSH 99
    ICONST_0
    IDIV
    INVOKEVIRTUAL java/io/PrintStream.println (I)V
    ALOAD 1
    ATHROW
   L3
    LINENUMBER 16 L3
   FRAME SAME
    GOTO L6
   L4
    LINENUMBER 14 L4
   FRAME SAME1 java/lang/Exception
    ASTORE 1
   L7
    LINENUMBER 15 L7
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    LDC "catch!!!"
    INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
   L6
    LINENUMBER 17 L6
   FRAME SAME
    RETURN
   L8
    LOCALVARIABLE e Ljava/lang/Exception; L7 L6 1
    LOCALVARIABLE args [Ljava/lang/String; L0 L8 0
    MAXSTACK = 3
    MAXLOCALS = 2
{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)

Reply via email to