[Soot-list] Do I understand traps?

Eric Bodden eric.bodden at ec-spride.de
Tue Jan 17 05:21:56 EST 2012


Are you maybe using an old/buggy version of Soot? For me Soot
generates this Jimple code, which has no traps:

   public void setCaretPosition(int)
    {
        javax.swing.text.JTextComponent r0;
        int i0, $i1;
        javax.swing.text.Document r1;
        java.lang.StringBuilder $r2, $r4, $r5;
        java.lang.IllegalArgumentException $r3;
        java.lang.String $r6;
        javax.swing.text.Caret $r7;

        r0 := @this: javax.swing.text.JTextComponent;
        i0 := @parameter0: int;
        r1 = virtualinvoke r0.<javax.swing.text.JTextComponent:
javax.swing.text.Document getDocument()>();
        if r1 == null goto label2;

        $i1 = interfaceinvoke r1.<javax.swing.text.Document: int getLength()>();
        if i0 > $i1 goto label0;

        if i0 >= 0 goto label1;

     label0:
        $r3 = new java.lang.IllegalArgumentException;
        $r2 = new java.lang.StringBuilder;
        specialinvoke $r2.<java.lang.StringBuilder: void <init>()>();
        $r4 = virtualinvoke $r2.<java.lang.StringBuilder:
java.lang.StringBuilder append(java.lang.String)>("bad position: ");
        $r5 = virtualinvoke $r4.<java.lang.StringBuilder:
java.lang.StringBuilder append(int)>(i0);
        $r6 = virtualinvoke $r5.<java.lang.StringBuilder:
java.lang.String toString()>();
        specialinvoke $r3.<java.lang.IllegalArgumentException: void
<init>(java.lang.String)>($r6);
        throw $r3;

     label1:
        $r7 = r0.<javax.swing.text.JTextComponent:
javax.swing.text.Caret caret>;
        interfaceinvoke $r7.<javax.swing.text.Caret: void setDot(int)>(i0);

     label2:
        return;
    }


Eric
On 17 January 2012 11:18, Martin Schäf <martinschaef at googlemail.com> wrote:
> Well, the thing with the throws clause is cool with me... but I do not
> understand why this method has a trap.
> If you look at the source code of javap
> javax.swing.text.JTextComponent (see my last email), the exception is
> not caught ...
> But the SootMethod definitely has a trap referring to a "r..:=
> $caughtexception ..$ statement which I do not see in the Java program.
>
>
> 2012/1/17 Eric Bodden <eric.bodden at ec-spride.de>:
>> Hi Martin.
>>
>> While this exception is documented in the JavaDoc, there is no actual
>> exception annotation on the method in the JDK's bytecode:
>>
>> $ javap javax.swing.text.JTextComponent | grep setCaretPosition
>>    public void setCaretPosition(int);
>>
>> You can also see it in the source...
>>
>>>            public void setCaretPosition(int position) {
>>
>> That's why Soot says that the method "does not throw anything".
>> Basically, this means that the method does not throw any *checked*
>> exceptions.
>>
>>> When debugging into the sootMethod, I find a trap that handles this
>>> exception including a catch-block, i.e., it is not thrown out.
>>
>> The trap would then originate from a try/catch block in the source
>> code this sootMethod was generated from.
>>
>> Eric



-- 
Eric Bodden, Ph.D., http://bodden.de/
Head of Secure Software Engineering Group at EC SPRIDE
Principal Investigator in Secure Services at CASED
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt


More information about the Soot-list mailing list