X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fexceptions.cpp;h=707efa4c31ea88a321104f91070972f9ae1c2a21;hb=a99db5e76512c854ef3800d53797ee54f3cd900f;hp=ec712c6f2e87aac39c5a8c4b90ec8d3846639229;hpb=17891dadc2f23425e7af6d5225f9a1610602ab6a;p=cacao.git diff --git a/src/vm/exceptions.cpp b/src/vm/exceptions.cpp index ec712c6f2..707efa4c3 100644 --- a/src/vm/exceptions.cpp +++ b/src/vm/exceptions.cpp @@ -1,6 +1,6 @@ -/* src/vm/exceptions.c - exception related functions +/* src/vm/exceptions.cpp - exception related functions - Copyright (C) 1996-2005, 2006, 2007, 2008 + Copyright (C) 1996-2011 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -29,48 +29,42 @@ #include #include #include -#include #include "vm/types.h" #include "md-abi.h" -#include "mm/memory.h" +#include "mm/memory.hpp" -#include "native/jni.h" #include "native/llni.h" -#include "native/native.h" +#include "native/native.hpp" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Thread.h" -#include "native/include/java_lang_Throwable.h" - -#include "threads/lock-common.h" +#include "threads/lock.hpp" #include "threads/thread.hpp" #include "toolbox/util.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.hpp" #include "vm/exceptions.hpp" #include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/loader.hpp" +#include "vm/method.hpp" +#include "vm/options.h" +#include "vm/os.hpp" #include "vm/string.hpp" #include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/methodheader.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/show.h" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/show.hpp" #include "vm/jit/stacktrace.hpp" #include "vm/jit/trace.hpp" -#include "vmcore/class.h" -#include "vmcore/globals.hpp" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/os.hpp" - #if defined(ENABLE_VMLOG) #include #endif @@ -246,7 +240,7 @@ static void exceptions_abort(utf *classname, utf *message) log_finish(); - vm_abort("Aborting..."); + os::abort("Aborting..."); } @@ -271,7 +265,7 @@ static java_handle_t *exceptions_new_class_utf(classinfo *c, utf *message) java_handle_t *s; java_handle_t *o; - if (vm->is_initializing()) { + if (VM::get_current()->is_initializing()) { /* This can happen when global class variables are used which are not initialized yet. */ @@ -309,7 +303,7 @@ static java_handle_t *exceptions_new_utf(utf *classname) classinfo *c; java_handle_t *o; - if (vm->is_initializing()) + if (VM::get_current()->is_initializing()) exceptions_abort(classname, NULL); c = load_class_bootstrap(classname); @@ -347,7 +341,7 @@ static java_handle_t *exceptions_new_utf_javastring(utf *classname, java_handle_t *o; classinfo *c; - if (vm->is_initializing()) + if (VM::get_current()->is_initializing()) exceptions_abort(classname, NULL); c = load_class_bootstrap(classname); @@ -384,7 +378,7 @@ static java_handle_t *exceptions_new_utf_utf(utf *classname, utf *message) classinfo *c; java_handle_t *o; - if (vm->is_initializing()) + if (VM::get_current()->is_initializing()) exceptions_abort(classname, message); c = load_class_bootstrap(classname); @@ -457,14 +451,12 @@ static void exceptions_throw_utf_throwable(utf *classname, java_handle_t *cause) { classinfo *c; - java_handle_t *o; methodinfo *m; - java_lang_Throwable *object; - if (vm->is_initializing()) + if (VM::get_current()->is_initializing()) exceptions_abort(classname, NULL); - object = (java_lang_Throwable *) cause; + java_lang_Throwable jlt(cause); c = load_class_bootstrap(classname); @@ -473,9 +465,9 @@ static void exceptions_throw_utf_throwable(utf *classname, /* create object */ - o = builtin_new(c); - - if (o == NULL) + java_handle_t* h = builtin_new(c); + + if (h == NULL) return; /* call initializer */ @@ -489,9 +481,9 @@ static void exceptions_throw_utf_throwable(utf *classname, if (m == NULL) return; - (void) vm_call_method(m, o, cause); + (void) vm_call_method(m, h, jlt.get_handle()); - exceptions_set_exception(o); + exceptions_set_exception(h); } @@ -513,7 +505,7 @@ static void exceptions_throw_utf_exception(utf *classname, java_handle_t *o; methodinfo *m; - if (vm->is_initializing()) + if (VM::get_current()->is_initializing()) exceptions_abort(classname, NULL); c = load_class_bootstrap(classname); @@ -558,43 +550,35 @@ static void exceptions_throw_utf_exception(utf *classname, static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause) { - classinfo *c; - java_handle_t *o; - methodinfo *m; - java_lang_String *s; - java_lang_Throwable *object; - - if (vm->is_initializing()) + if (VM::get_current()->is_initializing()) exceptions_abort(classname, NULL); - object = (java_lang_Throwable *) cause; + java_lang_Throwable jltcause(cause); - c = load_class_bootstrap(classname); + classinfo* c = load_class_bootstrap(classname); if (c == NULL) return; /* create object */ - o = builtin_new(c); + java_handle_t* h = builtin_new(c); - if (o == NULL) + if (h == NULL) return; /* call initializer */ - m = class_resolveclassmethod(c, - utf_init, - utf_java_lang_String__void, - NULL, - true); + methodinfo* m = class_resolveclassmethod(c, + utf_init, + utf_java_lang_String__void, + NULL, + true); if (m == NULL) return; - LLNI_field_get_ref(object, detailMessage, s); - - (void) vm_call_method(m, o, s); + (void) vm_call_method(m, h, jltcause.get_detailMessage()); /* call initCause */ @@ -607,9 +591,9 @@ static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause) if (m == NULL) return; - (void) vm_call_method(m, o, cause); + (void) vm_call_method(m, h, jltcause.get_handle()); - exceptions_set_exception(o); + exceptions_set_exception(h); } @@ -1906,34 +1890,26 @@ exceptions_handle_exception_return: void exceptions_print_exception(java_handle_t *xptr) { - java_lang_Throwable *t; -#if defined(ENABLE_JAVASE) - java_lang_Throwable *cause; -#endif - java_lang_String *s; - classinfo *c; - utf *u; + java_lang_Throwable jlt(xptr); - t = (java_lang_Throwable *) xptr; - - if (t == NULL) { + if (jlt.is_null()) { puts("NULL\n"); return; } #if defined(ENABLE_JAVASE) - LLNI_field_get_ref(t, cause, cause); + java_lang_Throwable jltcause(jlt.get_cause()); #endif /* print the root exception */ - LLNI_class_get(t, c); + classinfo* c = jlt.get_Class(); utf_display_printable_ascii_classname(c->name); - LLNI_field_get_ref(t, detailMessage, s); + java_lang_String jls(jlt.get_detailMessage()); - if (s != NULL) { - u = javastring_toutf((java_handle_t *) s, false); + if (!jls.is_null()) { + utf* u = javastring_toutf(jls.get_handle(), false); printf(": "); utf_display_printable_ascii(u); @@ -1944,16 +1920,17 @@ void exceptions_print_exception(java_handle_t *xptr) #if defined(ENABLE_JAVASE) /* print the cause if available */ - if ((cause != NULL) && (cause != t)) { + // FIXME cause != t compare with operator override. + if ((!jltcause.is_null()) && (jltcause.get_handle() != jlt.get_handle())) { printf("Caused by: "); - - LLNI_class_get(cause, c); + + c = jltcause.get_Class(); utf_display_printable_ascii_classname(c->name); - LLNI_field_get_ref(cause, detailMessage, s); + java_lang_String jlscause(jlt.get_detailMessage()); - if (s != NULL) { - u = javastring_toutf((java_handle_t *) s, false); + if (jlscause.get_handle() != NULL) { + utf* u = javastring_toutf(jlscause.get_handle(), false); printf(": "); utf_display_printable_ascii(u); @@ -2033,7 +2010,7 @@ void exceptions_print_stacktrace(void) false); if (m == NULL) - vm_abort("exceptions_print_stacktrace: printStackTrace()V not found"); + os::abort("exceptions_print_stacktrace: printStackTrace()V not found"); /* Print message. */ @@ -2044,7 +2021,7 @@ void exceptions_print_stacktrace(void) need it afterwards. */ t = thread_get_current(); - to = (java_lang_Thread *) thread_get_object(t); + to = (java_lang_Thread *) LLNI_WRAP(t->object); if (to != NULL) { fprintf(stderr, "in thread \"");