Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: exceptions.c 7671 2007-04-05 12:06:28Z twisti $
+ $Id: exceptions.c 8178 2007-07-05 11:13:20Z michi $
*/
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
#include "vm/types.h"
#include "native/jni.h"
#include "native/native.h"
+
#include "native/include/java_lang_String.h"
#include "native/include/java_lang_Throwable.h"
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#else
-# include "threads/none/threads.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
#include "toolbox/logging.h"
#include "toolbox/util.h"
#include "vm/jit/disass.h"
#include "vm/jit/jit.h"
#include "vm/jit/methodheader.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/stacktrace.h"
#include "vmcore/class.h"
#include "vmcore/loader.h"
+#include "vmcore/method.h"
#include "vmcore/options.h"
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* for raising exceptions from native methods *********************************/
bool exceptions_init(void)
{
+#if !(defined(__ARM__) && defined(__LINUX__))
+ /* On arm-linux the first memory page can't be mmap'ed, as it
+ contains the exception vectors. */
+
+ int pagesize;
+
+ /* mmap a memory page at address 0x0, so our hardware-exceptions
+ work. */
+
+ pagesize = getpagesize();
+
+ (void) memory_mmap_anon(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
+#endif
+
+ /* check if we get into trouble with our hardware-exceptions */
+
+ if (OFFSET(java_bytearray, data) <= EXCEPTION_HARDWARE_LARGEST)
+ vm_abort("signal_init: array-data offset is less or equal the maximum hardware-exception displacement: %d <= %d", OFFSET(java_bytearray, data), EXCEPTION_HARDWARE_LARGEST);
+
/* java/lang/Throwable */
if (!(class_java_lang_Throwable =
}
+/* exceptions_get_exception ****************************************************
+
+ Returns the current exception pointer of the current thread.
+
+*******************************************************************************/
+
+java_objectheader *exceptions_get_exception(void)
+{
+ /* return the exception */
+
+ return *exceptionptr;
+}
+
+
+/* exceptions_set_exception ****************************************************
+
+ Sets the exception pointer of the current thread.
+
+*******************************************************************************/
+
+void exceptions_set_exception(java_objectheader *o)
+{
+ /* set the exception */
+
+ *exceptionptr = o;
+}
+
+
+/* exceptions_clear_exception **************************************************
+
+ Clears the current exception pointer of the current thread.
+
+*******************************************************************************/
+
+void exceptions_clear_exception(void)
+{
+ exceptions_set_exception(NULL);
+}
+
+
+/* exceptions_get_and_clear_exception ******************************************
+
+ Gets the exception pointer of the current thread and clears it.
+ This function may return NULL.
+
+*******************************************************************************/
+
+java_objectheader *exceptions_get_and_clear_exception(void)
+{
+ java_objectheader *o;
+
+ /* get the exception */
+
+ o = exceptions_get_exception();
+
+ /* and clear the exception */
+
+ exceptions_clear_exception();
+
+ /* return the exception */
+
+ return o;
+}
+
+
/* exceptions_new_class ********************************************************
Creates an exception object from the given class and initalizes it.
o = native_new_and_init(c);
if (o == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
return o;
}
c = load_class_bootstrap(classname);
if (c == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
o = exceptions_new_class(c);
if (o == NULL)
return;
- *exceptionptr = o;
+ exceptions_set_exception(o);
}
static void exceptions_throw_utf_throwable(utf *classname,
java_objectheader *cause)
{
- java_objectheader *o;
+ classinfo *c;
+ java_objectheader *o;
+ methodinfo *m;
+ java_lang_Throwable *object;
+
+ object = (java_lang_Throwable *) cause;
+
+ c = load_class_bootstrap(classname);
+
+ if (c == NULL)
+ return;
+
+ /* create object */
+
+ o = builtin_new(c);
+
+ if (o == NULL)
+ return;
+
+ /* call initializer */
+
+ m = class_resolveclassmethod(c,
+ utf_init,
+ utf_java_lang_Throwable__void,
+ NULL,
+ true);
+
+ if (m == NULL)
+ return;
+
+ (void) vm_call_method(m, o, cause);
+
+ exceptions_set_exception(o);
+}
+
+
+/* exceptions_throw_utf_exception **********************************************
+
+ Creates an exception object with the given name and initalizes it
+ with the given java/lang/Exception exception.
+
+ IN:
+ classname....class name in UTF-8
+ exception....the given Exception
+
+*******************************************************************************/
+
+static void exceptions_throw_utf_exception(utf *classname,
+ java_objectheader *exception)
+{
classinfo *c;
-
+ java_objectheader *o;
+ methodinfo *m;
+
c = load_class_bootstrap(classname);
if (c == NULL)
return;
- o = native_new_and_init_throwable(c, cause);
+ /* create object */
+ o = builtin_new(c);
+
if (o == NULL)
return;
- *exceptionptr = o;
+ /* call initializer */
+
+ m = class_resolveclassmethod(c,
+ utf_init,
+ utf_java_lang_Exception__V,
+ NULL,
+ true);
+
+ if (m == NULL)
+ return;
+
+ (void) vm_call_method(m, o, exception);
+
+ exceptions_set_exception(o);
+}
+
+
+/* exceptions_throw_utf_cause **************************************************
+
+ Creates an exception object with the given name and initalizes it
+ with the given java/lang/Throwable exception with initCause.
+
+ IN:
+ classname....class name in UTF-8
+ cause........the given Throwable
+
+*******************************************************************************/
+
+static void exceptions_throw_utf_cause(utf *classname, java_objectheader *cause)
+{
+ classinfo *c;
+ java_objectheader *o;
+ methodinfo *m;
+ java_lang_Throwable *object;
+
+ object = (java_lang_Throwable *) cause;
+
+ c = load_class_bootstrap(classname);
+
+ if (c == NULL)
+ return;
+
+ /* create object */
+
+ o = builtin_new(c);
+
+ if (o == NULL)
+ return;
+
+ /* call initializer */
+
+ m = class_resolveclassmethod(c,
+ utf_init,
+ utf_java_lang_String__void,
+ NULL,
+ true);
+
+ if (m == NULL)
+ return;
+
+ (void) vm_call_method(m, o, object->detailMessage);
+
+ /* call initCause */
+
+ m = class_resolveclassmethod(c,
+ utf_initCause,
+ utf_java_lang_Throwable__java_lang_Throwable,
+ NULL,
+ true);
+
+ if (m == NULL)
+ return;
+
+ (void) vm_call_method(m, o, cause);
+
+ exceptions_set_exception(o);
}
c = load_class_bootstrap(classname);
if (c == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
o = native_new_and_init_string(c, message);
if (o == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
return o;
}
s = javastring_new(message);
if (s == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
o = native_new_and_init_string(c, s);
if (o == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
return o;
}
c = load_class_bootstrap(classname);
if (c == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
o = exceptions_new_class_utf(c, message);
}
-/* new_exception_message *******************************************************
-
- Creates an exception object with the given name and initalizes it
- with the given char message.
-
- IN:
- classname....class name in UTF-8
- message......message in UTF-8
-
- RETURN VALUE:
- an exception pointer (in any case -- either it is the newly created
- exception, or an exception thrown while trying to create it).
-
-*******************************************************************************/
-
-static java_objectheader *new_exception_message(const char *classname,
- const char *message)
-{
- java_objectheader *o;
- java_objectheader *s;
-
- s = javastring_new_from_utf_string(message);
-
- if (s == NULL)
- return *exceptionptr;
-
- o = exceptions_new_utf_javastring(classname, s);
-
- return o;
-}
-
-
/* exceptions_throw_class_utf **************************************************
Creates an exception object of the given class, initalizes and
static void exceptions_throw_class_utf(classinfo *c, utf *message)
{
- *exceptionptr = exceptions_new_class_utf(c, message);
+ java_objectheader *o;
+
+ o = exceptions_new_class_utf(c, message);
+
+ exceptions_set_exception(o);
}
*******************************************************************************/
static void exceptions_throw_utf_utf(utf *classname, utf *message)
-{
- *exceptionptr = exceptions_new_utf_utf(classname, message);
-}
-
-
-/* new_exception_int ***********************************************************
-
- Creates an exception object with the given name and initalizes it
- with the given int value.
-
- IN:
- classname....class name in UTF-8
- i............the integer
-
- RETURN VALUE:
- an exception pointer (in any case -- either it is the newly created
- exception, or an exception thrown while trying to create it).
-
-*******************************************************************************/
-
-java_objectheader *new_exception_int(const char *classname, s4 i)
{
java_objectheader *o;
- classinfo *c;
-
- if (!(c = load_class_bootstrap(utf_new_char(classname))))
- return *exceptionptr;
-
- o = native_new_and_init_int(c, i);
- if (!o)
- return *exceptionptr;
+ o = exceptions_new_utf_utf(classname, message);
- return o;
+ exceptions_set_exception(o);
}
classloader.
IN:
- c............the class in which the error was found
+ c....the class in which the error was found
*******************************************************************************/
void exceptions_throw_classcircularityerror(classinfo *c)
{
- java_objectheader *o;
- char *msg;
- s4 msglen;
-
- /* calculate message length */
-
- msglen = utf_bytes(c->name) + strlen("0");
-
- /* allocate a buffer */
-
- msg = MNEW(char, msglen);
-
- /* print message into allocated buffer */
-
- utf_copy_classname(msg, c->name);
-
- o = new_exception_message(utf_java_lang_ClassCircularityError, msg);
-
- MFREE(msg, char, msglen);
-
- if (o == NULL)
- return;
-
- *exceptionptr = o;
+ exceptions_throw_utf_utf(utf_java_lang_ClassCircularityError, c->name);
}
void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
{
- java_objectheader *o;
- char *msg;
- s4 msglen;
- va_list ap;
+ char *msg;
+ s4 msglen;
+ va_list ap;
+ utf *u;
/* calculate message length */
if (c != NULL)
strcat(msg, ")");
- o = new_exception_message(utf_java_lang_ClassFormatError, msg);
+ u = utf_new_char(msg);
+
+ /* free memory */
MFREE(msg, char, msglen);
- *exceptionptr = o;
+ /* throw exception */
+
+ exceptions_throw_utf_utf(utf_java_lang_ClassFormatError, u);
}
}
+/* exceptions_throw_noclassdeffounderror_cause *********************************
+
+ Generates and throws a java.lang.NoClassDefFoundError with the
+ given cause.
+
+*******************************************************************************/
+
+void exceptions_throw_noclassdeffounderror_cause(java_objectheader *cause)
+{
+ exceptions_throw_utf_cause(utf_java_lang_NoClassDefFoundError, cause);
+}
+
+
/* exceptions_throw_noclassdeffounderror_wrong_name ****************************
Generates and throws a java.lang.NoClassDefFoundError with a
specific message:
-
-
IN:
name.........name of the class not found as a utf *
}
-/* classnotfoundexception_to_noclassdeffounderror ******************************
-
- Check the *exceptionptr for a ClassNotFoundException. If it is one,
- convert it to a NoClassDefFoundError.
-
-*******************************************************************************/
-
-void classnotfoundexception_to_noclassdeffounderror(void)
-{
- java_objectheader *xptr;
- java_objectheader *cause;
- java_lang_Throwable *t;
- java_lang_String *s;
-
- /* get the cause */
-
- cause = *exceptionptr;
-
- /* convert ClassNotFoundException's to NoClassDefFoundError's */
-
- if (builtin_instanceof(cause, class_java_lang_ClassNotFoundException)) {
- /* clear exception, because we are calling jit code again */
-
- *exceptionptr = NULL;
-
- /* create new error */
-
- t = (java_lang_Throwable *) cause;
- s = t->detailMessage;
-
- xptr = exceptions_new_utf_javastring(utf_java_lang_NoClassDefFoundError, s);
-
- /* we had an exception while creating the error */
-
- if (*exceptionptr)
- return;
-
- /* set new exception */
-
- *exceptionptr = xptr;
- }
-}
-
-
/* exceptions_throw_exceptionininitializererror ********************************
Generates and throws a java.lang.ExceptionInInitializerError for
void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
{
- java_objectheader *o;
- char *msg;
- s4 msglen;
+ char *msg;
+ s4 msglen;
+ utf *u;
/* calculate exception message length */
utf_copy_classname(msg, c->name);
strcat(msg, message);
- o = native_new_and_init_string(utf_java_lang_IncompatibleClassChangeError,
- javastring_new_from_utf_string(msg));
+ u = utf_new_char(msg);
/* free memory */
MFREE(msg, char, msglen);
- if (o == NULL)
- return;
+ /* throw exception */
- *exceptionptr = o;
+ exceptions_throw_utf_utf(utf_java_lang_IncompatibleClassChangeError, u);
}
void exceptions_throw_internalerror(const char *message, ...)
{
- java_objectheader *o;
- va_list ap;
- char *msg;
- s4 msglen;
+ va_list ap;
+ char *msg;
+ s4 msglen;
+ utf *u;
/* calculate exception message length */
vsprintf(msg, message, ap);
va_end(ap);
- /* create exception object */
-
- o = new_exception_message(utf_java_lang_InternalError, msg);
+ u = utf_new_char(msg);
/* free memory */
MFREE(msg, char, msglen);
- if (o == NULL)
- return;
+ /* throw exception */
- *exceptionptr = o;
+ exceptions_throw_utf_utf(utf_java_lang_InternalError, u);
}
if (o == NULL)
return;
- *exceptionptr = o;
+ exceptions_set_exception(o);
}
void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi)
{
- java_objectheader *o;
- char *msg;
- s4 msglen;
+ char *msg;
+ s4 msglen;
+ utf *u;
/* calculate exception message length */
sprintf(msg + strlen(msg), " (Unsupported major.minor version %d.%d)",
ma, mi);
- /* create exception object */
-
- o = new_exception_message(utf_java_lang_UnsupportedClassVersionError, msg);
+ u = utf_new_char(msg);
/* free memory */
MFREE(msg, char, msglen);
- if (o == NULL)
- return;
+ /* throw exception */
- *exceptionptr = o;
+ exceptions_throw_utf_utf(utf_java_lang_UnsupportedClassVersionError, u);
}
void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...)
{
- java_objectheader *o;
- va_list ap;
- char *msg;
- s4 msglen;
+ va_list ap;
+ char *msg;
+ s4 msglen;
+ utf *u;
/* calculate exception message length */
vsprintf(msg + strlen(msg), message, ap);
va_end(ap);
- /* create exception object */
-
- o = new_exception_message(utf_java_lang_VerifyError, msg);
+ u = utf_new_char(msg);
/* free memory */
MFREE(msg, char, msglen);
- *exceptionptr = o;
+ /* throw exception */
+
+ exceptions_throw_utf_utf(utf_java_lang_VerifyError, u);
}
*******************************************************************************/
-void exceptions_throw_verifyerror_for_stack(methodinfo *m,int type)
+void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type)
{
- java_objectheader *o;
- char *msg;
- s4 msglen;
- char *typename;
+ char *msg;
+ s4 msglen;
+ char *typename;
+ utf *u;
/* calculate exception message length */
msglen = 0;
- if (m)
+ if (m != NULL)
msglen = strlen("(class: ") + utf_bytes(m->class->name) +
strlen(", method: ") + utf_bytes(m->name) +
strlen(" signature: ") + utf_bytes(m->descriptor) +
/* generate message */
- if (m) {
+ if (m != NULL) {
strcpy(msg, "(class: ");
utf_cat_classname(msg, m->class->name);
strcat(msg, ", method: ");
msg[0] = 0;
}
- strcat(msg,"Expecting to find ");
+ strcat(msg, "Expecting to find ");
+
switch (type) {
case TYPE_INT: typename = "integer"; break;
case TYPE_LNG: typename = "long"; break;
case TYPE_RET: typename = "returnAddress"; break;
default: typename = "<INVALID>"; assert(0); break;
}
+
strcat(msg, typename);
strcat(msg, " on stack");
- /* create exception object */
-
- o = new_exception_message(utf_java_lang_VerifyError, msg);
+ u = utf_new_char(msg);
/* free memory */
MFREE(msg, char, msglen);
- *exceptionptr = o;
+ /* throw exception */
+
+ exceptions_throw_utf_utf(utf_java_lang_VerifyError, u);
}
{
java_objectheader *o;
- o = new_exception_message(utf_java_lang_ArithmeticException, "/ by zero");
-
- if (o == NULL)
- return *exceptionptr;
+ o = exceptions_new_utf_utf(utf_java_lang_ArithmeticException,
+ utf_division_by_zero);
return o;
}
true);
if (m == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
s = vm_call_method(m, NULL, index);
if (s == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
o = exceptions_new_utf_javastring(utf_java_lang_ArrayIndexOutOfBoundsException,
s);
if (o == NULL)
- return *exceptionptr;
+ return exceptions_get_exception();
return o;
}
{
java_objectheader *e;
utf *classname;
- java_lang_String *s;
classname = o->vftbl->class->name;
- s = javastring_new(classname);
-
- e = native_new_and_init_string(class_java_lang_ClassCastException, s);
-
- if (e == NULL)
- return *exceptionptr;
+ e = exceptions_new_class_utf(class_java_lang_ClassCastException, classname);
return e;
}
*******************************************************************************/
-void exceptions_throw_illegalaccessexception(classinfo *c)
+void exceptions_throw_illegalaccessexception(utf *message)
{
- /* XXX handle argument */
-
- exceptions_throw_utf(utf_java_lang_IllegalAccessException);
+ exceptions_throw_utf_utf(utf_java_lang_IllegalAccessException, message);
}
}
+/* exceptions_throw_privilegedactionexception **********************************
+
+ Generates and throws a java.security.PrivilegedActionException.
+
+*******************************************************************************/
+
+void exceptions_throw_privilegedactionexception(java_objectheader *exception)
+{
+ exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException,
+ exception);
+}
+
+
/* exceptions_throw_stringindexoutofboundsexception ****************************
Generates and throws a java.lang.StringIndexOutOfBoundsException
}
-/* exceptions_get_exception ****************************************************
+/* exceptions_classnotfoundexception_to_noclassdeffounderror *******************
- Returns the current exception pointer of the current thread.
+ Check the exception for a ClassNotFoundException. If it is one,
+ convert it to a NoClassDefFoundError.
*******************************************************************************/
-java_objectheader *exceptions_get_exception(void)
+void exceptions_classnotfoundexception_to_noclassdeffounderror(void)
{
- /* return the exception */
-
- return *exceptionptr;
-}
+ java_objectheader *o;
+ java_objectheader *cause;
+ java_lang_Throwable *object;
+ java_objectheader *s;
+ /* get the cause */
-/* exceptions_set_exception ****************************************************
+ cause = exceptions_get_exception();
- Sets the exception pointer of the current thread.
+ /* convert ClassNotFoundException's to NoClassDefFoundError's */
-*******************************************************************************/
+ if (builtin_instanceof(cause, class_java_lang_ClassNotFoundException)) {
+ /* clear exception, because we are calling jit code again */
-void exceptions_set_exception(java_objectheader *o)
-{
- /* set the exception */
+ exceptions_clear_exception();
- *exceptionptr = o;
-}
+ /* create new error */
+ object = (java_lang_Throwable *) cause;
+ s = (java_objectheader *) object->detailMessage;
-/* exceptions_clear_exception **************************************************
+ o = exceptions_new_utf_javastring(utf_java_lang_NoClassDefFoundError,
+ s);
- Clears the current exception pointer of the current thread.
+ /* we had an exception while creating the error */
-*******************************************************************************/
+ if (exceptions_get_exception())
+ return;
-void exceptions_clear_exception(void)
-{
- /* and clear the exception */
+ /* set new exception */
- *exceptionptr = NULL;
+ exceptions_set_exception(o);
+ }
}
/* get exception */
- o = *exceptionptr;
- assert(o);
-
- /* clear exception */
+ o = exceptions_get_and_clear_exception();
- *exceptionptr = NULL;
+ assert(o);
/* resolve methodinfo pointer from exception object */
}
-/* exceptions_get_and_clear_exception ******************************************
-
- Gets the exception pointer of the current thread and clears it.
- This function may return NULL.
-
-*******************************************************************************/
-
-java_objectheader *exceptions_get_and_clear_exception(void)
-{
- java_objectheader **p;
- java_objectheader *e;
-
- /* get the pointer of the exception pointer */
-
- p = exceptionptr;
-
- /* get the exception */
-
- e = *p;
-
- /* and clear the exception */
-
- *p = NULL;
-
- /* return the exception */
-
- return e;
-}
-
-
/* exceptions_new_hardware_exception *******************************************
Creates the correct exception for a hardware-exception thrown and
*******************************************************************************/
-java_objectheader *exceptions_new_hardware_exception(u1 *pv, u1 *sp, u1 *ra, u1 *xpc, s4 type, ptrint val)
+java_objectheader *exceptions_new_hardware_exception(u1 *pv, u1 *sp, u1 *ra, u1 *xpc, s4 type, ptrint val, stackframeinfo *sfi)
{
- stackframeinfo sfi;
java_objectheader *e;
java_objectheader *o;
s4 index;
/* create stackframeinfo */
- stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+ stacktrace_create_extern_stackframeinfo(sfi, pv, sp, ra, xpc);
switch (type) {
case EXCEPTION_HARDWARE_NULLPOINTER:
e = exceptions_fillinstacktrace();
break;
+ case EXCEPTION_HARDWARE_PATCHER:
+ e = patcher_handler(xpc);
+ break;
+
default:
/* let's try to get a backtrace */
#endif
vm_abort("Exiting...");
+
+ /* keep compiler happy */
+
+ e = NULL;
}
/* remove stackframeinfo */
- stacktrace_remove_stackframeinfo(&sfi);
+ stacktrace_remove_stackframeinfo(sfi);
/* return the exception object */
#if !defined(NDEBUG)
/* print exception trace */
- if (opt_verbose || opt_verbosecall || opt_verboseexception)
+ if (opt_verbose || opt_verbosecall || opt_TraceExceptions)
builtin_trace_exception(xptr, m, xpc, 1);
#endif
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_throw(xptr);
+#endif
+
for (i = 0; i < exceptiontablelength; i++) {
/* ATTENTION: keep this here, as we need to decrement the
pointer before the loop executes! */
#if !defined(NDEBUG)
/* Print stacktrace of exception when caught. */
- if (opt_verboseexception) {
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_catch(xptr);
+#endif
+
+ if (opt_TraceExceptions) {
exceptions_print_exception(xptr);
stacktrace_print_trace(xptr);
}
#if !defined(NDEBUG)
/* Print stacktrace of exception when caught. */
- if (opt_verboseexception) {
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_catch(xptr);
+#endif
+
+ if (opt_TraceExceptions) {
exceptions_print_exception(xptr);
stacktrace_print_trace(xptr);
}
/* none of the exceptions catch this one */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_unwnd_method(m);
+#endif
+
return NULL;
}
#endif /* defined(ENABLE_JIT) */
utf_display_printable_ascii_classname(t->header.vftbl->class->name);
if (t->detailMessage != NULL) {
- u = javastring_toutf(t->detailMessage, false);
+ u = javastring_toutf((java_objectheader *) t->detailMessage, false);
printf(": ");
utf_display_printable_ascii(u);
printf("Caused by: ");
utf_display_printable_ascii_classname(cause->header.vftbl->class->name);
- if (cause->detailMessage) {
- u = javastring_toutf(cause->detailMessage, false);
+ if (cause->detailMessage != NULL) {
+ u = javastring_toutf((java_objectheader *) cause->detailMessage,
+ false);
printf(": ");
utf_display_printable_ascii(u);
void exceptions_print_current_exception(void)
{
- java_objectheader *xptr;
+ java_objectheader *o;
- xptr = *exceptionptr;
+ o = exceptions_get_exception();
- exceptions_print_exception(xptr);
+ exceptions_print_exception(o);
}
/* get original exception */
- oxptr = *exceptionptr;
+ oxptr = exceptions_get_and_clear_exception();
if (oxptr == NULL)
vm_abort("exceptions_print_stacktrace: no exception thrown");
/* clear exception, because we are calling jit code again */
- *exceptionptr = NULL;
-
c = oxptr->vftbl->class;
/* find the printStackTrace() method */
have a serious problem while printStackTrace. But may
be another exception, so print it. */
- xptr = *exceptionptr;
+ xptr = exceptions_get_exception();
if (xptr != NULL) {
fprintf(stderr, "Exception while printStackTrace(): ");