* Removed all Id tags.
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Throwable.c
1 /* src/native/vm/cldc1.1/java_lang_Throwable.c - java/lang/Throwable
2
3    Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25 */
26
27
28 #include "config.h"
29
30 #include <assert.h>
31
32 #include "vm/types.h"
33
34 #include "native/jni.h"
35 #include "native/native.h"
36
37 #include "native/include/java_lang_Object.h"
38 #include "native/include/java_lang_Throwable.h"
39
40 #include "vm/exceptions.h"
41 #include "vm/jit/stacktrace.h"
42
43
44 /* native methods implemented by this file ************************************/
45  
46 static JNINativeMethod methods[] = {
47         { "printStackTrace",  "()V", (void *) (ptrint) &Java_java_lang_Throwable_printStackTrace  },
48         { "fillInStackTrace", "()V", (void *) (ptrint) &Java_java_lang_Throwable_fillInStackTrace },
49 };
50
51
52 /* _Jv_java_lang_Throwable_init ************************************************
53  
54    Register native functions.
55  
56 *******************************************************************************/
57  
58 void _Jv_java_lang_Throwable_init(void)
59 {
60         utf *u;
61  
62         u = utf_new_char("java/lang/Throwable");
63  
64         native_method_register(u, methods, NATIVE_METHODS_COUNT);
65 }
66
67
68 /*
69  * Class:     java/lang/Throwable
70  * Method:    printStackTrace
71  * Signature: ()V
72  */
73 JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, java_lang_Throwable *this)
74 {
75         java_handle_t *o;
76
77         o = (java_handle_t *) this;
78
79         exceptions_print_exception(o);
80         stacktrace_print_trace(o);
81 }
82
83
84 /*
85  * Class:     java/lang/Throwable
86  * Method:    fillInStackTrace
87  * Signature: ()V
88  */
89 JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, java_lang_Throwable *this)
90 {
91         stacktracecontainer *stc;
92
93         stc = stacktrace_fillInStackTrace();
94
95         if (stc == NULL)
96                 return;
97
98         this->backtrace = (java_lang_Object *) stc;
99 }
100
101
102 /*
103  * These are local overrides for various environment variables in Emacs.
104  * Please do not remove this and leave it at the end of the file, where
105  * Emacs will automagically detect them.
106  * ---------------------------------------------------------------------
107  * Local variables:
108  * mode: c
109  * indent-tabs-mode: t
110  * c-basic-offset: 4
111  * tab-width: 4
112  * End:
113  */