- removed unused exception class_ declarations
[cacao.git] / src / native / native.h
1 /* native.h - table of native functions
2
3    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6    P. Tomsich, J. Wenninger
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: Reinhard Grafl
28
29    $Id: native.h 1001 2004-03-30 22:44:28Z twisti $
30
31 */
32
33
34 #ifndef _NATIVE_H
35 #define _NATIVE_H
36
37
38 #include "jni.h"
39 #include "nat/java_lang_String.h"
40 #include "nat/java_lang_ClassLoader.h"
41
42
43 /* searchpath for classfiles */
44 extern char *classpath;
45
46 extern classinfo *class_java_lang_Class;
47 extern classinfo *class_java_lang_VMClass;
48 /* extern classinfo *class_java_lang_Cloneable=0; */ /* now in global.h */
49 extern classinfo *class_java_lang_System;
50 extern classinfo *class_java_lang_ClassLoader;
51 extern classinfo *class_java_lang_Double;
52 extern classinfo *class_java_lang_Float;
53 extern classinfo *class_java_lang_Long;
54 extern classinfo *class_java_lang_Byte;
55 extern classinfo *class_java_lang_Short;
56 extern classinfo *class_java_lang_Boolean;
57 extern classinfo *class_java_lang_Void;
58 extern classinfo *class_java_lang_Character;
59 extern classinfo *class_java_lang_Integer;
60
61
62 /* specify some exception strings for code generation */
63
64 extern char *string_java_lang_ArithmeticException;
65 extern char *string_java_lang_ArithmeticException_message;
66 extern char *string_java_lang_ArrayIndexOutOfBoundsException;
67 extern char *string_java_lang_ArrayStoreException;
68 extern char *string_java_lang_ClassCastException;
69 extern char *string_java_lang_ClassNotFoundException;
70 extern char *string_java_lang_CloneNotSupportedException;
71 extern char *string_java_lang_IllegalArgumentException;
72 extern char *string_java_lang_NegativeArraySizeException;
73 extern char *string_java_lang_NoSuchFieldException;
74 extern char *string_java_lang_NoSuchMethodException;
75 extern char *string_java_lang_NullPointerException;
76
77
78 /* specify some error strings for code generation */
79
80 extern char *string_java_lang_ClassFormatError;
81 extern char *string_java_lang_LinkageError;
82 extern char *string_java_lang_NoClassDefFoundError;
83 extern char *string_java_lang_NoSuchFieldError;
84 extern char *string_java_lang_NoSuchMethodError;
85 extern char *string_java_lang_OutOfMemoryError;
86
87
88 /* the system classloader object */
89 extern struct java_lang_ClassLoader *SystemClassLoader;
90
91 /* for raising exceptions from native methods */
92 /* extern java_objectheader* exceptionptr; */
93
94 /* javastring-hashtable */
95 extern hashtable string_hash; 
96
97 /* throw an exception and exit */
98 void throw_exception_exit();
99
100 /* initialize new exceptions */
101 java_objectheader *new_exception(char *classname);
102 java_objectheader *new_exception_message(char *classname, char *message);
103 java_objectheader *new_exception_utfmessage(char *classname, utf *message);
104 java_objectheader *new_exception_javastring(char *classname, java_lang_String *message);
105 java_objectheader *new_exception_int(char *classname, s4 i);
106
107 void use_class_as_object(classinfo *c);
108
109 /* load classes required for native methods */
110 void native_loadclasses();
111
112 /* set searchpath for classfiles */
113 void native_setclasspath(char *path);
114
115 /* find native function */
116 functionptr native_findfunction(utf *cname, utf *mname, 
117                                                                 utf *desc, bool isstatic);
118
119 /* creates a new object of type java/lang/String from a utf-text */
120 /*  java_objectheader *javastring_new(utf *text); */
121 java_lang_String *javastring_new(utf *text);
122
123 /* creates a new object of type java/lang/String from a c-string */
124 /*  java_objectheader *javastring_new_char(char *text); */
125 java_lang_String *javastring_new_char(char *text);
126
127 /* make c-string from a javastring (debugging) */
128 char *javastring_tochar(java_objectheader *s);
129
130 /* create new object on the heap and call the initializer */
131 java_objectheader *native_new_and_init(classinfo *c);
132
133 /* create new object on the heap and call the initializer 
134    mainly used for exceptions with a message */
135 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
136 /* create new object on the heap and call the initializer 
137    mainly used for exceptions with an index */
138 java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
139
140 /* add property to system-property vector */
141 void attach_property(char *name, char *value);
142
143 /* correct vftbl-entries of javastring-hash */
144 void stringtable_update();
145
146
147 /* make utf symbol from javastring */
148 utf *javastring_toutf(struct java_lang_String *string, bool isclassname);
149
150 /* make utf symbol from u2 array */
151 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
152
153 /* determine utf length in bytes of a u2 array */
154 u4 u2_utflength(u2 *text, u4 u2_length);
155
156 /* create systemclassloader object and initialize its instance fields  */
157 void init_systemclassloader();
158
159 /* search 'classinfo'-structure for a field with the specified name */
160 fieldinfo *class_findfield_approx(classinfo *c, utf *name);
161 s4 class_findfield_index_approx(classinfo *c, utf *name);
162
163 /* creates a new javastring with the text of the utf-symbol */
164 java_objectheader *literalstring_new(utf *u);
165
166 /* creates a new javastring with the text of the u2-array */
167 java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset,
168                                                                         bool copymode);
169
170 /* dispose a javastring */
171 void literalstring_free(java_objectheader*);
172
173 void systemclassloader_addlibname(java_objectheader *o);
174 void systemclassloader_addlibrary(java_objectheader *o);
175
176 void copy_vftbl(vftbl **dest, vftbl *src);
177
178 utf *create_methodsig(java_objectarray* types, char *retType);
179 classinfo *get_type(char **utf_ptr,char *desc_end, bool skip);
180 java_objectarray* get_parametertypes(methodinfo *m);
181 java_objectarray* get_exceptiontypes(methodinfo *m);
182 classinfo *get_returntype(methodinfo *m);
183
184
185
186
187 java_objectarray *builtin_asm_createclasscontextarray(classinfo **end,classinfo **start);
188 java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end,classinfo **start);
189
190 #endif /* _NATIVE_H */
191
192
193 /*
194  * These are local overrides for various environment variables in Emacs.
195  * Please do not remove this and leave it at the end of the file, where
196  * Emacs will automagically detect them.
197  * ---------------------------------------------------------------------
198  * Local variables:
199  * mode: c
200  * indent-tabs-mode: t
201  * c-basic-offset: 4
202  * tab-width: 4
203  * End:
204  */