Changes:
- $Id: exceptions.c 2193 2005-04-02 19:33:43Z edwin $
+ $Id: exceptions.c 2276 2005-04-12 19:47:33Z twisti $
*/
#include "native/include/java_lang_String.h"
#include "native/include/java_lang_Throwable.h"
#include "toolbox/logging.h"
+#include "toolbox/util.h"
#include "vm/class.h"
#include "vm/exceptions.h"
#include "vm/global.h"
{
/* java/lang/Throwable */
- if (!load_class_bootstrap(utf_java_lang_Throwable,&class_java_lang_Throwable) ||
+ if (!load_class_bootstrap(utf_java_lang_Throwable,
+ &class_java_lang_Throwable) ||
!link_class(class_java_lang_Throwable))
return false;
- /* java/lang/Exception */
+ /* java/lang/VMThrowable */
- if (!load_class_bootstrap(utf_java_lang_Exception,&class_java_lang_Exception) ||
- !link_class(class_java_lang_Exception))
+ if (!load_class_bootstrap(utf_java_lang_VMThrowable,
+ &class_java_lang_VMThrowable) ||
+ !link_class(class_java_lang_VMThrowable))
return false;
/* java/lang/Error */
- if (!load_class_bootstrap(utf_java_lang_Error,&class_java_lang_Error) ||
+ if (!load_class_bootstrap(utf_java_lang_Error, &class_java_lang_Error) ||
!link_class(class_java_lang_Error))
return false;
+ /* java/lang/Exception */
+
+ if (!load_class_bootstrap(utf_java_lang_Exception,
+ &class_java_lang_Exception) ||
+ !link_class(class_java_lang_Exception))
+ return false;
+
+
+ /* java/lang/NoClassDefFoundError */
+
+ if (!load_class_bootstrap(utf_java_lang_NoClassDefFoundError,
+ &class_java_lang_NoClassDefFoundError) ||
+ !link_class(class_java_lang_NoClassDefFoundError))
+ return false;
+
+
/* java/lang/OutOfMemoryError */
- if (!load_class_bootstrap(utf_java_lang_OutOfMemoryError,&class_java_lang_OutOfMemoryError) ||
+ if (!load_class_bootstrap(utf_java_lang_OutOfMemoryError,
+ &class_java_lang_OutOfMemoryError) ||
!link_class(class_java_lang_OutOfMemoryError))
return false;
+
+ /* java/lang/ClassNotFoundException */
+
+ if (!load_class_bootstrap(utf_java_lang_ClassNotFoundException,
+ &class_java_lang_ClassNotFoundException) ||
+ !link_class(class_java_lang_ClassNotFoundException))
+ return false;
+
return true;
}
{
classinfo *c;
- if (!load_class_bootstrap(utf_new_char(classname),&c))
+ if (!load_class_bootstrap(utf_new_char(classname), &c))
return *exceptionptr;
return native_new_and_init(c);
{
classinfo *c;
- if (!load_class_bootstrap(utf_new_char(classname),&c))
+ if (!load_class_bootstrap(utf_new_char(classname), &c))
return *exceptionptr;
{
classinfo *c;
- if (!load_class_bootstrap(utf_new_char(classname),&c))
+ if (!load_class_bootstrap(utf_new_char(classname), &c))
return *exceptionptr;
{
classinfo *c;
- if (!load_class_bootstrap(utf_new_char(classname),&c))
+ if (!load_class_bootstrap(utf_new_char(classname), &c))
return *exceptionptr;
{
classinfo *c;
- if (!load_class_bootstrap(utf_new_char(classname),&c))
+ if (!load_class_bootstrap(utf_new_char(classname), &c))
return *exceptionptr;
{
classinfo *c;
- if (!load_class_bootstrap(utf_new_char(classname),&c))
+ if (!load_class_bootstrap(utf_new_char(classname), &c))
return *exceptionptr;
return native_new_and_init_int(c, i);
java_objectheader *new_classformaterror(classinfo *c, const char *message, ...)
{
- char msg[MAXLOGTEXT];
- va_list ap;
+ java_objectheader *o;
+ char *msg;
+ s4 msglen;
+ va_list ap;
- utf_sprint_classname(msg, c->name);
- sprintf(msg + strlen(msg), " (");
+ /* calculate message length */
+
+ if (c)
+ msglen = utf_strlen(c->name) + strlen(" (");
+
+ va_start(ap, message);
+ msglen += get_variable_message_length(message, ap);
+ va_end(ap);
+
+ if (c)
+ msglen += strlen(")");
+
+ msglen += strlen("0");
+
+ /* allocate a buffer */
+
+ msg = MNEW(char, msglen);
+
+ /* print message into allocated buffer */
+
+ if (c) {
+ utf_sprint_classname(msg, c->name);
+ strcat(msg, " (");
+ }
va_start(ap, message);
vsprintf(msg + strlen(msg), message, ap);
va_end(ap);
- sprintf(msg + strlen(msg), ")");
+ if (c)
+ strcat(msg, ")");
+
+ o = new_exception_message(string_java_lang_ClassFormatError, msg);
- return new_exception_message(string_java_lang_ClassFormatError, msg);
+ MFREE(msg, char, msglen);
+
+ return o;
}
-/* vm/exceptions.h - exception related functions prototypes
+/* src/vm/exceptions.h - exception related functions prototypes
Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
Authors: Christian Thalinger
- $Id: exceptions.h 2181 2005-04-01 16:53:33Z edwin $
+ Changes:
+
+ $Id: exceptions.h 2276 2005-04-12 19:47:33Z twisti $
*/
#ifndef _EXCEPTIONS_H
#define _EXCEPTIONS_H
-
#include "vm/global.h"
#include "native/include/java_lang_String.h"
#include "native/include/java_lang_Throwable.h"
/* exception/error super class */
extern const char *string_java_lang_Throwable;
+extern const char *string_java_lang_VMThrowable;
/* specify some exception strings for code generation */