[kaffe] Updated patch...

Godmar Back gback@stanford.edu
Tue, 21 May 2002 11:59:19 -0600 (MDT)


> 
> 
> --- Godmar Back <gback@cs.utah.edu> wrote:
> > 
> >  Jukka, about the patch below:
> > 
> > The "FIXME" was referring to the fact that instead
> > of SignalError,
> > postExceptionMessage() followed by throwError()
> > should be used
> > and the name of the missing field should be
> > reported.
> > 
> > 	- Godmar
> > 
> > -      
> > SignalError("java.lang.NoSuchFieldException", "");
> > /* FIXME */
> > +       /* like SignalError, except that the name of
> > the field that is
> > +        * not found becomes the error message
> > +        */
> > +       throwException((struct
> > Hjava_lang_Throwable*)execute_java_constructor(
> > +               "java.lang.NoSuchFieldException", 0,
> > 0,
> > +               "(Ljava/lang/String;)V", name));
> >
> 
> I applied the patch as it was. If I've understood
> Godmar properly I shall be looking forward to a one
> liner fix removing the FIXME?
> 

No, what I meant is that "throwException()" and "execute_java_constructor()"
are not functions you should use for that purpose in the native
libraries.  Instead, you should (roughly) use this sequence of calls:

{
    errorInfo info;
    postExceptionMessage(&info, JAVA_LANG(NoSuchFieldError), // or Exception?
	"class `%s' does not have a field called `%s', ..., ....);  
	// or whatever informative error msg you prefer here
    throwError(&info);
}

Take a look at kaffevm/exception.c:error2Throwable; this function
should be used to construct the Throwable in an Exception/Error.

If you don't like it that way, you can write a wrapper function for
the above, add it to exception.c and call that wrapper.

	- Godmar