-/* src/vm/exceptions.c - exception related functions
+/* src/vm/exceptions.cpp - exception related functions
Copyright (C) 1996-2005, 2006, 2007, 2008
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
-#include <sys/mman.h>
#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/system.h"
-
#if defined(ENABLE_VMLOG)
#include <vmlog_cacao.h>
#endif
log_finish();
- vm_abort("Aborting...");
+ os::abort("Aborting...");
}
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. */
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);
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);
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);
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);
/* create object */
- o = builtin_new(c);
-
- if (o == NULL)
+ java_handle_t* h = builtin_new(c);
+
+ if (h == NULL)
return;
/* call initializer */
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);
}
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);
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 */
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);
}
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);
#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);
false);
if (m == NULL)
- vm_abort("exceptions_print_stacktrace: printStackTrace()V not found");
+ os::abort("exceptions_print_stacktrace: printStackTrace()V not found");
/* Print message. */