|
From: Gilbert C. H. II <gc...@mi...> - 2001-08-25 17:17:30
|
At 06:54 PM 8/24/01 -0400, "Todd L. Miller" <tm...@ha...> wrote:
>> How do I create an instance of an error? It might be possible to create an
>> error factory. An error factory would make it easier to construct different
>> errors through a single method.
>>
>> How does the scheduler "know" that one of its threads has thrown an error?
>> When an error is thrown, the message should be displayed prominently on the
>> console, right? We need to know why it failed.
>
> You know, GCHII, these are very good questions. The design I had
>(all interpreter methods take an exception reference to fill in -- should
>have been Throwable, because of errors -- incidentally) was a Grade A hack
>designed around jJOS not supporting C++ exceptions, which seem the natural
>way to do things. I don't know what the right answer is; maybe Leuner has
>a clue?
Exceptions (java/lang/Throwable) were thrown and caught properly in version
1i--within the bytecode; the exception test ran to completion. I added an
"Exception" property to the frame class in C++. It is a pointer to a
java_object. The runOpcode() method checks the Exception property after it
invokes an opcode method. If an exception (java/lang/Throwable) is thrown,
it invokes handleException(). If handleException() can't handle an
exception, it (re)sets the Exception property of the frame. To calculate
the exception properly within the exception table, I also added the
exceptionPC property to the frame class.
But, exceptions need to be thrown from machine code, too. I felt that I was
pretty close to a solution. I was thinking of something like this:
class java_throwable : public java_object {
: ???
}
There are lots of throwable classes in Java. But, I can't justify
maintaining so many classes in C++. I don't want to create a class in C++
for each throwable class in Java.
What if java_throwable had a classname property? A pseudo-classname might
be assigned in a constructor:
java_throwable e = new java_throwable( "java/lang/VirtualMachineError" ); ???
|