more stacktraces
[cacao.git] / src / vm / exceptions.h
1 /* src/vm/exceptions.h - exception related functions prototypes
2
3    Copyright (C) 1996-2005 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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: exceptions.h 2360 2005-04-24 13:07:57Z jowenn $
32
33 */
34
35
36 #ifndef _EXCEPTIONS_H
37 #define _EXCEPTIONS_H
38
39 #include "vm/global.h"
40 #include "native/include/java_lang_String.h"
41 #include "native/include/java_lang_Throwable.h"
42 #include "vm/builtin.h"
43 #include "vm/references.h"
44 #include "vm/method.h"
45
46
47 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
48
49 #define exceptionptr                     builtin_get_exceptionptrptr()
50 #define dontfillinexceptionstacktrace    builtin_get_dontfillinexceptionstacktrace()
51 #define threadrootmethod                 builtin_get_threadrootmethod()
52
53 #else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
54
55 #define exceptionptr        (&_exceptionptr)
56 #define dontfillinexceptionstacktrace (&_dontfillinexceptionstacktrace)
57 #define threadrootmethod    (&_threadrootmethod)
58
59 #endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
60
61 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
62 extern java_objectheader *_exceptionptr;
63 extern u1 _dontfillinexceptionstacktrace;
64 extern methodinfo* _threadrootmethod;
65 #endif /* !defined(USE_THREADS) || !defined(NATIVE_THREADS) */
66
67
68 /* global variables ***********************************************************/
69
70 /* exception/error super class */
71
72 extern const char *string_java_lang_Throwable;
73 extern const char *string_java_lang_VMThrowable;
74
75
76 /* specify some exception strings for code generation */
77
78 extern const char *string_java_lang_ArithmeticException;
79 extern const char *string_java_lang_ArithmeticException_message;
80 extern const char *string_java_lang_ArrayIndexOutOfBoundsException;
81 extern const char *string_java_lang_ArrayStoreException;
82 extern const char *string_java_lang_ClassCastException;
83 extern const char *string_java_lang_ClassNotFoundException;
84 extern const char *string_java_lang_CloneNotSupportedException;
85 extern const char *string_java_lang_Exception;
86 extern const char *string_java_lang_IllegalAccessException;
87 extern const char *string_java_lang_IllegalArgumentException;
88 extern const char *string_java_lang_IllegalMonitorStateException;
89 extern const char *string_java_lang_IndexOutOfBoundsException;
90 extern const char *string_java_lang_InstantiationException;
91 extern const char *string_java_lang_InterruptedException;
92 extern const char *string_java_lang_NegativeArraySizeException;
93 extern const char *string_java_lang_NoSuchFieldException;
94 extern const char *string_java_lang_NoSuchMethodException;
95 extern const char *string_java_lang_NullPointerException;
96
97
98 /* specify some error strings for code generation */
99
100 extern const char *string_java_lang_AbstractMethodError;
101 extern const char *string_java_lang_ClassCircularityError;
102 extern const char *string_java_lang_ClassFormatError;
103 extern const char *string_java_lang_Error;
104 extern const char *string_java_lang_ExceptionInInitializerError;
105 extern const char *string_java_lang_IncompatibleClassChangeError;
106 extern const char *string_java_lang_InternalError;
107 extern const char *string_java_lang_LinkageError;
108 extern const char *string_java_lang_NoClassDefFoundError;
109 extern const char *string_java_lang_NoSuchFieldError;
110 extern const char *string_java_lang_NoSuchMethodError;
111 extern const char *string_java_lang_OutOfMemoryError;
112 extern const char *string_java_lang_UnsupportedClassVersionError;
113 extern const char *string_java_lang_VerifyError;
114 extern const char *string_java_lang_VirtualMachineError;
115
116
117 /* function prototypes ********************************************************/
118
119 /* load and link exceptions used in the system */
120
121 bool exceptions_init(void);
122
123
124 /* exception throwing functions */
125
126 void throw_exception();
127 void throw_exception_exit();
128
129 void throw_main_exception();
130 void throw_main_exception_exit();
131
132 void throw_cacao_exception_exit(const char *exception, const char *message, ...);
133
134
135 /* initialize new exceptions */
136
137 java_objectheader *new_exception(const char *classname);
138
139 java_objectheader *new_exception_message(const char *classname,
140                                                                                  const char *message);
141
142 java_objectheader *new_exception_throwable(const char *classname,
143                                                                                    java_lang_Throwable *cause);
144
145 java_objectheader *new_exception_utfmessage(const char *classname,
146                                                                                         utf *message);
147
148 java_objectheader *new_exception_javastring(const char *classname,
149                                                                                         java_lang_String *message);
150
151 java_objectheader *new_exception_int(const char *classname, s4 i);
152
153
154 /* functions to generate compiler exceptions */
155
156 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
157 java_objectheader *new_internalerror(const char *message, ...);
158 java_objectheader *new_verifyerror(methodinfo *m, const char *message);
159 java_objectheader *new_unsupportedclassversionerror(classinfo *c,
160                                                                                                         const char *message, ...);
161
162 java_objectheader *new_arithmeticexception();
163 java_objectheader *new_arrayindexoutofboundsexception(s4 index);
164 java_objectheader *new_arraystoreexception();
165 java_objectheader *new_classcastexception();
166 java_objectheader *new_negativearraysizeexception();
167 java_objectheader *new_nullpointerexception();
168
169 #endif /* _EXCEPTIONS_H */
170
171
172 /*
173  * These are local overrides for various environment variables in Emacs.
174  * Please do not remove this and leave it at the end of the file, where
175  * Emacs will automagically detect them.
176  * ---------------------------------------------------------------------
177  * Local variables:
178  * mode: c
179  * indent-tabs-mode: t
180  * c-basic-offset: 4
181  * tab-width: 4
182  * End:
183  */