* src/vm/suck.c (suck_add): Use vm_abort instead of
[cacao.git] / src / vm / exceptions.h
1 /* src/vm/exceptions.h - exception related functions prototypes
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, 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    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28             Edwin Steiner
29
30    $Id: exceptions.h 6286 2007-01-10 10:03:38Z twisti $
31
32 */
33
34
35 #ifndef _EXCEPTIONS_H
36 #define _EXCEPTIONS_H
37
38 /* forward typedefs ***********************************************************/
39
40 #include "config.h"
41 #include "vm/types.h"
42
43 #include "vm/global.h"
44 #include "native/jni.h"
45 #include "native/include/java_lang_String.h"
46 #include "native/include/java_lang_Throwable.h"
47 #include "vm/builtin.h"
48 #include "vm/references.h"
49 #include "vm/method.h"
50
51
52 /* hardware-exception defines **************************************************
53
54    These defines define the load-offset which indicates the given
55    exception.
56
57    ATTENTION: These offsets need NOT to be aligned to 4 or 8-byte
58    boundaries, since normal loads could have such offsets with a base
59    of NULL which should result in a NullPointerException.
60
61 *******************************************************************************/
62
63 #define EXCEPTION_LOAD_DISP_NULLPOINTER              0
64 #define EXCEPTION_LOAD_DISP_ARITHMETIC               1
65 #define EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS    2
66 #define EXCEPTION_LOAD_DISP_CLASSCAST                3
67
68 #define EXCEPTION_LOAD_DISP_PATCHER                  5
69
70
71 /* exception pointer **********************************************************/
72
73 #if defined(ENABLE_THREADS)
74 #define exceptionptr    &(THREADOBJECT->_exceptionptr)
75 #else
76 #define exceptionptr    &_no_threads_exceptionptr
77 #endif
78
79 #if !defined(ENABLE_THREADS)
80 extern java_objectheader *_no_threads_exceptionptr;
81 #endif
82
83
84 /* function prototypes ********************************************************/
85
86 /* load and link exceptions used in the system */
87 bool exceptions_init(void);
88
89
90 /* exception throwing functions */
91
92 void throw_exception(void);
93 void throw_exception_exit(void);
94
95 void throw_main_exception(void);
96 void throw_main_exception_exit(void);
97
98 void throw_cacao_exception_exit(const char *exception,
99                                                                 const char *message, ...);
100
101
102 /* initialize new exceptions */
103
104 java_objectheader *new_exception(const char *classname);
105
106 java_objectheader *new_exception_message(const char *classname,
107                                                                                  const char *message);
108
109 java_objectheader *new_exception_throwable(const char *classname,
110                                                                                    java_lang_Throwable *cause);
111
112 java_objectheader *new_exception_utfmessage(const char *classname,
113                                                                                         utf *message);
114
115 java_objectheader *new_exception_javastring(const char *classname,
116                                                                                         java_lang_String *message);
117
118 java_objectheader *new_exception_int(const char *classname, s4 i);
119
120
121 /* functions to generate compiler exceptions */
122
123 #if defined(ENABLE_JAVASE)
124 java_objectheader *exceptions_new_abstractmethoderror(void);
125 void               exceptions_throw_abstractmethoderror(void);
126 #endif
127
128 java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
129
130 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
131 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...);
132
133 java_objectheader *new_classnotfoundexception(utf *name);
134 java_objectheader *new_noclassdeffounderror(utf *name);
135 java_objectheader *exceptions_new_linkageerror(const char *message,classinfo *c);
136
137 #if defined(ENABLE_JAVASE)
138 java_objectheader *exceptions_new_nosuchmethoderror(classinfo *c,
139                                                                                                         utf *name, utf *desc);
140 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc);
141 #endif
142
143 void exceptions_throw_internalerror(const char *message, ...);
144
145 void exceptions_throw_outofmemoryerror(void);
146
147 java_objectheader *exceptions_new_verifyerror(methodinfo *m,
148                                                                                           const char *message, ...);
149 void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...);
150 void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type);
151
152 java_objectheader *exceptions_new_virtualmachineerror(void);
153 void               exceptions_throw_virtualmachineerror(void);
154
155 java_objectheader *new_unsupportedclassversionerror(classinfo *c,
156                                                                                                         const char *message, ...);
157
158 java_objectheader *new_arithmeticexception(void);
159
160 java_objectheader *new_arrayindexoutofboundsexception(s4 index);
161 void exceptions_throw_arrayindexoutofboundsexception(void);
162
163 java_objectheader *exceptions_new_arraystoreexception(void);
164 void exceptions_throw_arraystoreexception(void);
165
166 java_objectheader *exceptions_new_classcastexception(java_objectheader *o);
167
168 java_objectheader *new_illegalargumentexception(void);
169 void exceptions_throw_illegalargumentexception(void);
170
171 java_objectheader *exceptions_new_illegalmonitorstateexception(void);
172 void               exceptions_throw_illegalmonitorstateexception(void);
173
174 java_objectheader *new_negativearraysizeexception(void);
175 void exceptions_throw_negativearraysizeexception(void);
176
177 java_objectheader *exceptions_new_nullpointerexception(void);
178 void exceptions_throw_nullpointerexception(void);
179
180 java_objectheader *exceptions_new_stringindexoutofboundsexception(void);
181 void exceptions_throw_stringindexoutofboundsexception(void);
182
183 void classnotfoundexception_to_noclassdeffounderror(void);
184
185 java_objectheader *exceptions_get_and_clear_exception(void);
186
187 void exceptions_print_exception(java_objectheader *xptr);
188
189 #endif /* _EXCEPTIONS_H */
190
191
192 /*
193  * These are local overrides for various environment variables in Emacs.
194  * Please do not remove this and leave it at the end of the file, where
195  * Emacs will automagically detect them.
196  * ---------------------------------------------------------------------
197  * Local variables:
198  * mode: c
199  * indent-tabs-mode: t
200  * c-basic-offset: 4
201  * tab-width: 4
202  * End:
203  * vim:noexpandtab:sw=4:ts=4:
204  */