[Mono-list] exceptions and ECMA issues

Paolo Molaro lupus@debian.org
Tue, 21 Aug 2001 19:27:47 +0200


Hi.
In the last few days I implemented most of the exception handling
code for the mono interpreter (filter blocks and rethrow are missing),
so, if you download the next snapshot you will be able to play
with this code: make sure to report any bugs you may find.
You'll also need the latest corlib.dll from mcs.

Now, there are a couple of issues with the spec.

1) fault blocks: the spec says that they must be ended with an
endfault opcode, but I couldn't find an endfault specification
in partition III.

2) rethrow opcode. It is not clear where the search for an handler
should begin after a rethrow: should it start from the beginning,
from the last handler found or from the parent method?
Consider:

using System;

public class MyEx : Exception {
	public MyEx () {}
}

public class Ex {

	public static int test (int a) {
		int res;
		int fin = 0;
		try {
			res = 10/a;
			throw new MyEx ();
		} catch (Exception ex) {
			ex = new MyEx ();
			throw; // <---- RETHROW
		} finally {
			fin = 1;
		}
		return res;
	}
	public static int Main () {
		int catched = 0;
		try {
			test (1);
		} catch (MyEx ex) {
			catched = 1;
		}
		if (catched != 1)
			return 2;
		try {
			test (0);
		} catch (MyEx ex) {
			catched = 2;
		} catch {
			// we should get here because rethrow rethrows the dividebyzero ex
			// not the exception assigned to the local var
			catched = 3;
		}
		if (catched != 3)
			return 3;
		return 0;
	}
}

Restarting from the beginning will result in an infinite loop,
so, what other option should I choose?

Thanks,
	lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better