955ef4d5539441b92bdbfe883f55e99bc5546193
[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 3264 2005-09-21 20:18:24Z twisti $
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 #define exceptionptr    builtin_get_exceptionptrptr()
49 #else
50 #define exceptionptr    &_no_threads_exceptionptr
51 #endif
52
53 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
54 extern java_objectheader *_no_threads_exceptionptr;
55 #endif
56
57
58 /* global variables ***********************************************************/
59
60
61 /* function prototypes ********************************************************/
62
63 /* load and link exceptions used in the system */
64
65 bool exceptions_init(void);
66
67
68 /* exception throwing functions */
69
70 void throw_exception();
71 void throw_exception_exit();
72
73 void throw_main_exception();
74 void throw_main_exception_exit();
75
76 void throw_cacao_exception_exit(const char *exception, const char *message, ...);
77
78
79 /* initialize new exceptions */
80
81 java_objectheader *new_exception(const char *classname);
82
83 java_objectheader *new_exception_message(const char *classname,
84                                                                                  const char *message);
85
86 java_objectheader *new_exception_throwable(const char *classname,
87                                                                                    java_lang_Throwable *cause);
88
89 java_objectheader *new_exception_utfmessage(const char *classname,
90                                                                                         utf *message);
91
92 java_objectheader *new_exception_javastring(const char *classname,
93                                                                                         java_lang_String *message);
94
95 java_objectheader *new_exception_int(const char *classname, s4 i);
96
97
98 /* functions to generate compiler exceptions */
99
100 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
101 java_objectheader *new_classnotfoundexception(utf *name);
102 java_objectheader *new_internalerror(const char *message, ...);
103 java_objectheader *new_verifyerror(methodinfo *m, const char *message, ...);
104 java_objectheader *new_unsupportedclassversionerror(classinfo *c,
105                                                                                                         const char *message, ...);
106
107 java_objectheader *new_arithmeticexception();
108 java_objectheader *new_arrayindexoutofboundsexception(s4 index);
109 java_objectheader *new_arraystoreexception();
110 java_objectheader *new_classcastexception();
111 java_objectheader *new_negativearraysizeexception();
112 java_objectheader *new_nullpointerexception();
113
114 #endif /* _EXCEPTIONS_H */
115
116
117 /*
118  * These are local overrides for various environment variables in Emacs.
119  * Please do not remove this and leave it at the end of the file, where
120  * Emacs will automagically detect them.
121  * ---------------------------------------------------------------------
122  * Local variables:
123  * mode: c
124  * indent-tabs-mode: t
125  * c-basic-offset: 4
126  * tab-width: 4
127  * End:
128  */