[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question re. compilation of exceptions/monitors in Jimple (fwd)





+-------------------------------------------------------------+
| Professor Laurie Hendren, School of Computer Science        |
| McGill University                                           |
| 318 McConnell Engineering Building      tel: (514) 398-7391 |
| 3480 University Street                  fax: (514) 398-3883 |
| Montreal, Quebec H3A 2A7               hendren@cs.mcgill.ca |
| CANADA                  http://www.sable.mcgill.ca/~hendren |
+-------------------------------------------------------------+

---------- Forwarded message ----------
Date: Wed, 24 Apr 2002 18:17:17 +0200
From: Jean-Pierre Talpin <Jean-Pierre.Talpin@irisa.fr>
To: hendren@sable.mcgill.ca
Subject: Question re. compilation of exceptions/monitors in Jimple

Dear Laurie Hendren,

I would have a technical question regarding the translation of exceptions/monitors in
Jimple. Sorry for addressing it directly to you, may be you could just pass it to the person
who implements/maintain Jimple.

The question is about the interaction between exceptions and monitors. It works perfectly in
almost all programs we have compiled/tested so far.  There is one example (attached) in
which we do not know or understand whether a monitor should be released or not
(enter/release of monitors are vital in the use we are making of Jimple, as they mark
(blocks of) atomic transitions for our model-checker).

In the example (method called ''essai''), consider the ''exception from label0 to label14
with label15'' statement and the program label4. At label4, monitor r9 is entered. When the
goto from label4 to label10 is performed, exception r23 is thrown and catched by label15.
But monitor r9 is not released by label15 or label16? Is this a correct understanding of the
handling of r23 at label10, or is label12 invoked instead of label15 (from ''throwable from
label2 to label11 with label12'') ?

Best regards,

Jean-Pierre.

import javax.realtime.*;

class MEE {
	public MEE() {
	       
	}
	public static void essai() {
		ImmortalMemory immortalMA = ImmortalMemory.instance();
		String z;
		
		System.out.println("Hello");	
	
		try {
		     z = (String)immortalMA.newInstance(Class.forName("java.lang.Integer"));
		     System.out.println(z);
		}
		catch (Exception e) {};
			
			
		System.out.println("Bye");
			
	}
	public static void main (String[] args) {
		
		MEE objet = new MEE ();
		essai();
	}
}



class MEE extends java.lang.Object
{

    public void <init>()
    {
        MEE r0;

        r0 := @this: MEE;
        specialinvoke r0.<java.lang.Object: void <init>()>();
        return;
    }

    public static void essai()
    {
        java.lang.String r1;
        java.io.PrintStream $r3, $r6, $r8;
        java.lang.Class $r4;
        java.lang.Exception $r7;
        javax.realtime.ImmortalMemory $r9;
        java.lang.NullPointerException r10, r23;
        java.lang.Throwable r11, $r20;
        java.lang.ClassCastException $r17;
        java.lang.RuntimeException $r18;
        java.lang.Object r19;
        java.lang.Thread $r21;
        javax.realtime.RealtimeThread $r22;
        javax.realtime.MemoryArea $r25;

        $r9 = <javax.realtime.ImmortalMemory: javax.realtime.ImmortalMemory mem>;
        $r3 = <java.lang.System: java.io.PrintStream out>;
        virtualinvoke $r3.<java.io.PrintStream: void println(java.lang.String)>("Hello");

     label0:
        $r4 = staticinvoke <java.lang.Class: java.lang.Class forName(java.lang.String)>("java.lang.Integer");
        if $r9 != null goto label1;

        r10 = new java.lang.NullPointerException;
        specialinvoke r10.<java.lang.NullPointerException: void <init>()>();
        throw r10;

     label1:
        entermonitor $r9;

     label2:
        $r21 = staticinvoke <java.lang.Thread: java.lang.Thread currentThread()>();
        $r22 = (javax.realtime.RealtimeThread) $r21;
        goto label4;

     label3:
        $r17 := @caughtexception;
        $r18 = new java.lang.RuntimeException;
        specialinvoke $r18.<java.lang.RuntimeException: void <init>(java.lang.String)>("The method \"enter\" must be called from a RealtimeThread");
        throw $r18;

     label4:
        if $r22 == null goto label10;

        $r25 = $r22.<javax.realtime.RealtimeThread: javax.realtime.MemoryArea memoryArea_>;
        virtualinvoke $r9.<javax.realtime.MemoryArea: void activate()>();

     label5:
        r19 = virtualinvoke $r4.<java.lang.Class: java.lang.Object newInstance()>();
        goto label8;

     label6:
        $r20 := @caughtexception;
        goto label9;

     label7:
        throw $r20;

     label8:
        virtualinvoke $r25.<javax.realtime.MemoryArea: void activate()>();
        goto label11;

     label9:
        virtualinvoke $r25.<javax.realtime.MemoryArea: void activate()>();
        goto label7;

     label10:
        r23 = new java.lang.NullPointerException;
        specialinvoke r23.<java.lang.NullPointerException: void <init>()>();
        throw r23;

     label11:
        exitmonitor $r9;
        goto label13;

     label12:
        r11 := @caughtexception;
        exitmonitor $r9;
        throw r11;

     label13:
        r1 = (java.lang.String) r19;
        $r6 = <java.lang.System: java.io.PrintStream out>;
        virtualinvoke $r6.<java.io.PrintStream: void println(java.lang.String)>(r1);

     label14:
        goto label16;

     label15:
        $r7 := @caughtexception;

     label16:
        $r8 = <java.lang.System: java.io.PrintStream out>;
        virtualinvoke $r8.<java.io.PrintStream: void println(java.lang.String)>("Bye");
        return;

        catch java.lang.Throwable from label5 to label6 with label6;
        catch java.lang.ClassCastException from label2 to label3 with label3;
        catch java.lang.Throwable from label2 to label11 with label12;
        catch java.lang.Exception from label0 to label14 with label15;
    }

    public static void main(java.lang.String[])
    {
        java.lang.String[] r0;
        MEE $r1;
        java.lang.String r4;
        java.io.PrintStream $r6, $r9, $r11;
        java.lang.Class $r7;
        java.lang.Exception $r10;
        javax.realtime.ImmortalMemory $r12;
        java.lang.NullPointerException r13, r26;
        java.lang.Throwable r14, $r23;
        java.lang.ClassCastException $r20;
        java.lang.RuntimeException $r21;
        java.lang.Object r22;
        java.lang.Thread $r24;
        javax.realtime.RealtimeThread $r25;
        javax.realtime.MemoryArea $r28;

        r0 := @parameter0: java.lang.String[];
        $r1 = new MEE;
        specialinvoke $r1.<MEE: void <init>()>();
        $r12 = <javax.realtime.ImmortalMemory: javax.realtime.ImmortalMemory mem>;
        $r6 = <java.lang.System: java.io.PrintStream out>;
        virtualinvoke $r6.<java.io.PrintStream: void println(java.lang.String)>("Hello");

     label0:
        $r7 = staticinvoke <java.lang.Class: java.lang.Class forName(java.lang.String)>("java.lang.Integer");
        if $r12 != null goto label1;

        r13 = new java.lang.NullPointerException;
        specialinvoke r13.<java.lang.NullPointerException: void <init>()>();
        throw r13;

     label1:
        entermonitor $r12;

     label2:
        $r24 = staticinvoke <java.lang.Thread: java.lang.Thread currentThread()>();
        $r25 = (javax.realtime.RealtimeThread) $r24;
        goto label4;

     label3:
        $r20 := @caughtexception;
        $r21 = new java.lang.RuntimeException;
        specialinvoke $r21.<java.lang.RuntimeException: void <init>(java.lang.String)>("The method \"enter\" must be called from a RealtimeThread");
        throw $r21;

     label4:
        if $r25 == null goto label10;

        $r28 = $r25.<javax.realtime.RealtimeThread: javax.realtime.MemoryArea memoryArea_>;
        virtualinvoke $r12.<javax.realtime.MemoryArea: void activate()>();

     label5:
        r22 = virtualinvoke $r7.<java.lang.Class: java.lang.Object newInstance()>();
        goto label8;

     label6:
        $r23 := @caughtexception;
        goto label9;

     label7:
        throw $r23;

     label8:
        virtualinvoke $r28.<javax.realtime.MemoryArea: void activate()>();
        goto label11;

     label9:
        virtualinvoke $r28.<javax.realtime.MemoryArea: void activate()>();
        goto label7;

     label10:
        r26 = new java.lang.NullPointerException;
        specialinvoke r26.<java.lang.NullPointerException: void <init>()>();
        throw r26;

     label11:
        exitmonitor $r12;
        goto label13;

     label12:
        r14 := @caughtexception;
        exitmonitor $r12;
        throw r14;

     label13:
        r4 = (java.lang.String) r22;
        $r9 = <java.lang.System: java.io.PrintStream out>;
        virtualinvoke $r9.<java.io.PrintStream: void println(java.lang.String)>(r4);

     label14:
        goto label16;

     label15:
        $r10 := @caughtexception;

     label16:
        $r11 = <java.lang.System: java.io.PrintStream out>;
        virtualinvoke $r11.<java.io.PrintStream: void println(java.lang.String)>("Bye");
        return;

        catch java.lang.Exception from label0 to label14 with label15;
        catch java.lang.Throwable from label2 to label11 with label12;
        catch java.lang.ClassCastException from label2 to label3 with label3;
        catch java.lang.Throwable from label5 to label6 with label6;
    }
}