* This commit implementes C++ wrapper classes for CLDC 1.1. Again to
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Throwable.cpp
index 905ff2dc0b6ba4f90e0c5fbb90479f5f1c2a2387..cdd6a6c86c21eb0178a7588d670768d2765adc79 100644 (file)
 #include "native/llni.h"
 #include "native/native.h"
 
-#include "native/include/java_lang_Object.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Throwable.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Throwable.h"
+#endif
 
 #include "vm/exceptions.hpp"
-#include "vm/jit/stacktrace.hpp"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { (char*) "printStackTrace",  (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_printStackTrace  },
-       { (char*) "fillInStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace },
-};
 
+#include "vm/jit/stacktrace.hpp"
 
-/* _Jv_java_lang_Throwable_init ************************************************
-   Register native functions.
-*******************************************************************************/
-// FIXME
-extern "C" {
-void _Jv_java_lang_Throwable_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Throwable");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
+#include "vmcore/javaobjects.hpp"
 
 
 // Native functions are exported as C functions.
@@ -78,14 +51,12 @@ extern "C" {
  * Method:    printStackTrace
  * Signature: ()V
  */
-JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, java_lang_Throwable *_this)
+JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, jobject _this)
 {
-       java_handle_t *o;
-
-       o = (java_handle_t *) _this;
+       java_lang_Throwable jlt(_this);
 
-       exceptions_print_exception(o);
-       stacktrace_print_exception(o);
+       exceptions_print_exception(jlt.get_handle());
+       stacktrace_print_exception(jlt.get_handle());
 }
 
 
@@ -94,21 +65,47 @@ JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, jav
  * Method:    fillInStackTrace
  * Signature: ()V
  */
-JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, java_lang_Throwable *_this)
+JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject _this)
 {
-       java_handle_bytearray_t *ba;
-
-       ba = stacktrace_get_current();
+       java_handle_bytearray_t* ba = stacktrace_get_current();
 
        if (ba == NULL)
                return;
 
-       LLNI_field_set_ref(_this, backtrace, (java_lang_Object *) ba);
+       java_lang_Throwable jlt(_this);
+       jlt.set_backtrace(ba);
 }
 
 } // extern "C"
 
 
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "printStackTrace",  (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_printStackTrace  },
+       { (char*) "fillInStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace },
+};
+
+
+/* _Jv_java_lang_Throwable_init ************************************************
+   Register native functions.
+*******************************************************************************/
+// FIXME
+extern "C" {
+void _Jv_java_lang_Throwable_init(void)
+{
+       utf *u;
+       u = utf_new_char("java/lang/Throwable");
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where