#include "native/jni.hpp"
#include "native/llni.h"
-#include "native/native.h"
+#include "native/native.hpp"
#if defined(ENABLE_JNI_HEADERS)
# include "native/vm/include/java_lang_VMThrowable.h"
#endif
-#include "vm/array.h"
+#include "vm/array.hpp"
#include "vm/jit/builtin.hpp"
#include "vm/exceptions.hpp"
#include "vm/globals.hpp"
#include "vm/string.hpp"
#include "vm/jit/code.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
#include "vm/jit/stacktrace.hpp"
// Get the stacktrace from the VMThrowable object.
- java_handle_bytearray_t* ba = vmt.get_vmdata();
+ ByteArray ba(vmt.get_vmdata());
// XXX Critical GC section?
- stacktrace_t* st = (stacktrace_t*) LLNI_array_data(ba);
+ stacktrace_t* st = (stacktrace_t*) ba.get_raw_data_ptr();
assert(st != NULL);
- stacktrace_entry_t* ste = st->entries;
-
- /* Create the stacktrace element array. */
-
- java_handle_objectarray_t* oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
-
- if (oa == NULL)
- return NULL;
-
- for (int i = 0; i < st->length; i++, ste++) {
- /* Get the codeinfo and methodinfo. */
-
- codeinfo* code = ste->code;
- methodinfo* m = code->m;
-
- /* Get filename. */
-
- java_handle_t* filename;
-
- if (!(m->flags & ACC_NATIVE)) {
- if (m->clazz->sourcefile)
- filename = javastring_new(m->clazz->sourcefile);
- else
- filename = NULL;
- }
- else
- filename = NULL;
-
- /* get line number */
-
- int32_t linenumber;
-
- if (m->flags & ACC_NATIVE) {
- linenumber = -1;
- }
- else {
- /* FIXME The linenumbertable_linenumber_for_pc could
- change the methodinfo pointer when hitting an inlined
- method. */
-
- linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
- linenumber = (linenumber == 0) ? -1 : linenumber;
- }
-
- /* get declaring class name */
-
- java_handle_t* declaringclass = class_get_classname(m->clazz);
-
- /* allocate a new stacktrace element */
-
- java_handle_t* h = builtin_new(class_java_lang_StackTraceElement);
-
- if (h == NULL)
- return NULL;
-
- java_lang_StackTraceElement ste(h, filename, linenumber, declaringclass, javastring_new(m->name), ((m->flags & ACC_NATIVE) ? 1 : 0));
-
- array_objectarray_element_set(oa, i, ste.get_handle());
- }
-
- return (jobjectArray) oa;
+ return stacktrace_get_StackTraceElements(st);
}
} // extern "C"
*******************************************************************************/
-extern "C" {
void _Jv_java_lang_VMThrowable_init(void)
{
- utf *u;
-
- u = utf_new_char("java/lang/VMThrowable");
+ utf* u = utf_new_char("java/lang/VMThrowable");
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
+ NativeMethods& nm = VM::get_current()->get_nativemethods();
+ nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
}