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