- added: string_java_lang_VMThrowable
[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 2276 2005-04-12 19:47:33Z 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
49 #define exceptionptr        builtin_get_exceptionptrptr()
50 #define threadrootmethod    builtin_get_threadrootmethod()
51
52 #else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
53
54 #define exceptionptr        (&_exceptionptr)
55 #define threadrootmethod    (&_threadrootmethod)
56
57 #endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
58
59 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
60 extern java_objectheader *_exceptionptr;
61 extern methodinfo* _threadrootmethod;
62 #endif /* !defined(USE_THREADS) || !defined(NATIVE_THREADS) */
63
64
65 /* global variables ***********************************************************/
66
67 /* exception/error super class */
68
69 extern const char *string_java_lang_Throwable;
70 extern const char *string_java_lang_VMThrowable;
71
72
73 /* specify some exception strings for code generation */
74
75 extern const char *string_java_lang_ArithmeticException;
76 extern const char *string_java_lang_ArithmeticException_message;
77 extern const char *string_java_lang_ArrayIndexOutOfBoundsException;
78 extern const char *string_java_lang_ArrayStoreException;
79 extern const char *string_java_lang_ClassCastException;
80 extern const char *string_java_lang_ClassNotFoundException;
81 extern const char *string_java_lang_CloneNotSupportedException;
82 extern const char *string_java_lang_Exception;
83 extern const char *string_java_lang_IllegalAccessException;
84 extern const char *string_java_lang_IllegalArgumentException;
85 extern const char *string_java_lang_IllegalMonitorStateException;
86 extern const char *string_java_lang_IndexOutOfBoundsException;
87 extern const char *string_java_lang_InstantiationException;
88 extern const char *string_java_lang_InterruptedException;
89 extern const char *string_java_lang_NegativeArraySizeException;
90 extern const char *string_java_lang_NoSuchFieldException;
91 extern const char *string_java_lang_NoSuchMethodException;
92 extern const char *string_java_lang_NullPointerException;
93
94
95 /* specify some error strings for code generation */
96
97 extern const char *string_java_lang_AbstractMethodError;
98 extern const char *string_java_lang_ClassCircularityError;
99 extern const char *string_java_lang_ClassFormatError;
100 extern const char *string_java_lang_Error;
101 extern const char *string_java_lang_ExceptionInInitializerError;
102 extern const char *string_java_lang_IncompatibleClassChangeError;
103 extern const char *string_java_lang_InternalError;
104 extern const char *string_java_lang_LinkageError;
105 extern const char *string_java_lang_NoClassDefFoundError;
106 extern const char *string_java_lang_NoSuchFieldError;
107 extern const char *string_java_lang_NoSuchMethodError;
108 extern const char *string_java_lang_OutOfMemoryError;
109 extern const char *string_java_lang_UnsupportedClassVersionError;
110 extern const char *string_java_lang_VerifyError;
111 extern const char *string_java_lang_VirtualMachineError;
112
113
114 /* function prototypes ********************************************************/
115
116 /* load and link exceptions used in the system */
117
118 bool exceptions_init(void);
119
120
121 /* exception throwing functions */
122
123 void throw_exception();
124 void throw_exception_exit();
125
126 void throw_main_exception();
127 void throw_main_exception_exit();
128
129 void throw_cacao_exception_exit(const char *exception, const char *message, ...);
130
131
132 /* initialize new exceptions */
133
134 java_objectheader *new_exception(const char *classname);
135
136 java_objectheader *new_exception_message(const char *classname,
137                                                                                  const char *message);
138
139 java_objectheader *new_exception_throwable(const char *classname,
140                                                                                    java_lang_Throwable *cause);
141
142 java_objectheader *new_exception_utfmessage(const char *classname,
143                                                                                         utf *message);
144
145 java_objectheader *new_exception_javastring(const char *classname,
146                                                                                         java_lang_String *message);
147
148 java_objectheader *new_exception_int(const char *classname, s4 i);
149
150
151 /* functions to generate compiler exceptions */
152
153 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
154 java_objectheader *new_internalerror(const char *message, ...);
155 java_objectheader *new_verifyerror(methodinfo *m, const char *message);
156 java_objectheader *new_unsupportedclassversionerror(classinfo *c,
157                                                                                                         const char *message, ...);
158
159 java_objectheader *new_arithmeticexception();
160 java_objectheader *new_arrayindexoutofboundsexception(s4 index);
161 java_objectheader *new_arraystoreexception();
162 java_objectheader *new_classcastexception();
163 java_objectheader *new_negativearraysizeexception();
164 java_objectheader *new_nullpointerexception();
165
166 #endif /* _EXCEPTIONS_H */
167
168
169 /*
170  * These are local overrides for various environment variables in Emacs.
171  * Please do not remove this and leave it at the end of the file, where
172  * Emacs will automagically detect them.
173  * ---------------------------------------------------------------------
174  * Local variables:
175  * mode: c
176  * indent-tabs-mode: t
177  * c-basic-offset: 4
178  * tab-width: 4
179  * End:
180  */