[Soot-list] Extra athrow instruction in a finally block

Alvin Yan feiya200 at cs.uregina.ca
Thu Mar 6 14:00:47 EST 2008


Hmmm, no. For example a code piece:
try{
	a();
}catch(Exception e){

}finally{
	System.out.println();
}

will be compiled to 

    TRYCATCHBLOCK L0 L1 L2 java/lang/Exception
    TRYCATCHBLOCK L0 L3 L4 
   L0 (0)
    LINENUMBER 8 L0
    ALOAD 0
    INVOKEVIRTUAL Test.a()V
   L1 (3)
    GOTO L5
   L2 (5)
    LINENUMBER 9 L2
   FRAME SAME1 java/lang/Exception
    ASTORE 1
   L3 (8)
    LINENUMBER 12 L3
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    INVOKEVIRTUAL java/io/PrintStream.println()V
    GOTO L6
   L4 (12)
    LINENUMBER 11 L4
   FRAME SAME1 java/lang/Throwable
    ASTORE 2
   L7 (15)
    LINENUMBER 12 L7
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    INVOKEVIRTUAL java/io/PrintStream.println()V
   L8 (18)
    LINENUMBER 13 L8
    ALOAD 2
    ATHROW
   L5 (21)
    LINENUMBER 12 L5
   FRAME SAME
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    INVOKEVIRTUAL java/io/PrintStream.println()V
   L6 (25)
    LINENUMBER 14 L6
   FRAME SAME

I'm just wondering why there is that ATHROW?
Thanks a lot!

Alvin

--------------------------------------------------
From: "Eric Bodden" <eric.bodden at mail.mcgill.ca>
Sent: Thursday, March 06, 2008 8:24 AM
To: "Alvin Yan" <feiya200 at cs.uregina.ca>
Cc: <soot-list at sable.mcgill.ca>
Subject: Re: [Soot-list] Extra athrow instruction in a finally block

> You mean code like that?
> 
> try{
> ...
> } finally {
>  throw e; //(x)
> }
> 
> Certainly line (x) is an exit point for this method because an
> exception *will* be thrown at this point. The try/finally construct
> only guards the "try" part, not the "finally" part.
> 
> Eric 


More information about the Soot-list mailing list