* Merged in twisti-branch.
[cacao.git] / src / vm / exceptions.h
1 /* src/vm/exceptions.h - exception related functions prototypes
2
3    Copyright (C) 1996-2005, 2006, 2007 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    $Id: exceptions.h 7596 2007-03-28 21:05:53Z twisti $
26
27 */
28
29
30 #ifndef _EXCEPTIONS_H
31 #define _EXCEPTIONS_H
32
33 /* forward typedefs ***********************************************************/
34
35 #include "config.h"
36 #include "vm/types.h"
37
38 #include "vm/global.h"
39
40 #include "vmcore/references.h"
41 #include "vmcore/method.h"
42
43
44 /* hardware-exception defines **************************************************
45
46    These defines define an internal number for the various hardware
47    exceptions.
48
49    ATTENTION: These values are also used as load-displacements on some
50    architectures. Thus, these values must NOT be aligned to 4 or
51    8-byte boundaries, since normal loads could have such offsets with
52    a base of NULL which should result in a NullPointerException.
53
54 *******************************************************************************/
55
56 #define EXCEPTION_HARDWARE_NULLPOINTER              0
57 #define EXCEPTION_HARDWARE_ARITHMETIC               1
58 #define EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS    2
59 #define EXCEPTION_HARDWARE_CLASSCAST                3
60
61 #define EXCEPTION_HARDWARE_EXCEPTION                5
62
63 #define EXCEPTION_HARDWARE_PATCHER                  6
64
65
66 /* exception pointer **********************************************************/
67
68 #if defined(ENABLE_THREADS)
69 #define exceptionptr    &(THREADOBJECT->_exceptionptr)
70 #else
71 #define exceptionptr    &_no_threads_exceptionptr
72 #endif
73
74 #if !defined(ENABLE_THREADS)
75 extern java_objectheader *_no_threads_exceptionptr;
76 #endif
77
78
79 /* function prototypes ********************************************************/
80
81 /* load and link exceptions used in the system */
82 bool exceptions_init(void);
83
84 /* initialize new exceptions */
85
86 java_objectheader *new_exception_utfmessage(const char *classname,
87                                                                                         utf *message);
88
89 java_objectheader *new_exception_int(const char *classname, s4 i);
90
91
92 /* functions to generate compiler exceptions */
93
94 java_objectheader *exceptions_new_abstractmethoderror(void);
95 java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
96 java_objectheader *exceptions_new_arraystoreexception(void);
97
98 void exceptions_throw_abstractmethoderror(void);
99 void exceptions_throw_classcircularityerror(classinfo *c);
100 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...);
101 void exceptions_throw_classnotfoundexception(utf *name);
102 void exceptions_throw_noclassdeffounderror(utf *name);
103 void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name);
104 void exceptions_throw_linkageerror(const char *message, classinfo *c);
105 void exceptions_throw_nosuchfielderror(classinfo *c, utf *name);
106 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc);
107 void exceptions_throw_exceptionininitializererror(java_objectheader *cause);
108 void exceptions_throw_incompatibleclasschangeerror(classinfo *c,
109                                                                                                    const char *message);
110 void exceptions_throw_instantiationerror(classinfo *c);
111 void exceptions_throw_internalerror(const char *message, ...);
112 void exceptions_throw_outofmemoryerror(void);
113 void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...);
114 void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type);
115 void exceptions_throw_unsatisfiedlinkerror(utf *name);
116 void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi);
117
118 java_objectheader *exceptions_new_arithmeticexception(void);
119
120 java_objectheader *exceptions_new_arrayindexoutofboundsexception(s4 index);
121 void exceptions_throw_arrayindexoutofboundsexception(void);
122 void exceptions_throw_arraystoreexception(void);
123
124 java_objectheader *exceptions_new_classcastexception(java_objectheader *o);
125
126 void exceptions_throw_clonenotsupportedexception(void);
127 void exceptions_throw_illegalaccessexception(classinfo *c);
128 void exceptions_throw_illegalargumentexception(void);
129 void exceptions_throw_illegalmonitorstateexception(void);
130 void exceptions_throw_interruptedexception(void);
131 void exceptions_throw_instantiationexception(classinfo *c);
132 void exceptions_throw_invocationtargetexception(java_objectheader *cause);
133 void exceptions_throw_negativearraysizeexception(void);
134
135 java_objectheader *exceptions_new_nullpointerexception(void);
136 void exceptions_throw_nullpointerexception(void);
137 void exceptions_throw_stringindexoutofboundsexception(void);
138
139 java_objectheader *exceptions_fillinstacktrace(void);
140
141 void classnotfoundexception_to_noclassdeffounderror(void);
142
143 java_objectheader *exceptions_get_exception(void);
144 void               exceptions_set_exception(java_objectheader *o);
145 void               exceptions_clear_exception(void);
146 java_objectheader *exceptions_get_and_clear_exception(void);
147
148 java_objectheader *exceptions_new_hardware_exception(u1 *pv, u1 *sp, u1 *ra, u1 *xpc, s4 type, ptrint val);
149
150 void exceptions_print_exception(java_objectheader *xptr);
151 void exceptions_print_current_exception(void);
152 void exceptions_print_stacktrace(void);
153
154 #endif /* _EXCEPTIONS_H */
155
156
157 /*
158  * These are local overrides for various environment variables in Emacs.
159  * Please do not remove this and leave it at the end of the file, where
160  * Emacs will automagically detect them.
161  * ---------------------------------------------------------------------
162  * Local variables:
163  * mode: c
164  * indent-tabs-mode: t
165  * c-basic-offset: 4
166  * tab-width: 4
167  * End:
168  * vim:noexpandtab:sw=4:ts=4:
169  */