reflection, loader fix (before it did offer an unloaded (not found) class as loaded...
[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 682 2003-12-01 15:33:30Z jowenn $
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
41
42 /* searchpath for classfiles */
43 extern char *classpath;
44
45 extern classinfo *class_java_lang_Class;
46 extern classinfo *class_java_lang_VMClass;
47 extern methodinfo *method_vmclass_init;
48 /* extern classinfo *class_java_lang_Cloneable=0; */ /* now in global.h */
49 extern classinfo *class_java_lang_CloneNotSupportedException;
50 extern classinfo *class_java_lang_System;
51 extern classinfo *class_java_lang_ClassLoader;
52 extern classinfo *class_java_lang_ClassNotFoundException;
53 extern classinfo *class_java_lang_InstantiationException;
54 extern classinfo *class_java_lang_NoSuchMethodError;   
55 extern classinfo *class_java_lang_NoSuchFieldError;
56 extern classinfo *class_java_lang_ClassFormatError;
57 extern classinfo *class_java_lang_IllegalArgumentException;
58 extern classinfo *class_java_lang_ArrayIndexOutOfBoundsException;
59 extern classinfo *class_java_lang_NoSuchFieldException;
60 extern classinfo *class_java_io_SyncFailedException;
61 extern classinfo *class_java_io_IOException;
62 extern classinfo *class_java_io_FileNotFoundException;
63 extern classinfo *class_java_io_UnixFileSystem;
64 extern classinfo *class_java_security_PrivilegedActionException;
65 extern classinfo *class_java_net_UnknownHostException;
66 extern classinfo *class_java_net_SocketException;
67 extern classinfo *class_java_lang_NoSuchMethodException;
68 extern classinfo *class_java_lang_Double;
69 extern classinfo *class_java_lang_Float;
70 extern classinfo *class_java_lang_Long;
71 extern classinfo *class_java_lang_Byte;
72 extern classinfo *class_java_lang_Short;
73 extern classinfo *class_java_lang_Boolean;
74 extern classinfo *class_java_lang_Void;
75 extern classinfo *class_java_lang_Character;
76 extern classinfo *class_java_lang_Integer;
77
78 /* the system classloader object */
79 extern struct java_lang_ClassLoader *SystemClassLoader;
80
81 /* for raising exceptions from native methods */
82 extern java_objectheader* exceptionptr;
83
84 /* javastring-hashtable */
85 extern hashtable string_hash; 
86
87
88 void use_class_as_object(classinfo *c);
89
90 /* load classes required for native methods */
91 void native_loadclasses();
92
93 /* set searchpath for classfiles */
94 void native_setclasspath(char *path);
95
96 /* find native function */
97 functionptr native_findfunction(utf *cname, utf *mname, 
98                                                                 utf *desc, bool isstatic);
99
100 /* creates a new object of type java/lang/String from a utf-text */
101 java_objectheader *javastring_new(utf *text);
102
103 /* creates a new object of type java/lang/String from a c-string */
104 java_objectheader *javastring_new_char(char *text);
105
106 /* make c-string from a javastring (debugging) */
107 char *javastring_tochar(java_objectheader *s);
108
109 /* create new object on the heap and call the initializer */
110 java_objectheader *native_new_and_init(classinfo *c);
111
112 /* 
113    create new object on the heap and call the initializer 
114    mainly used for exceptions with a message
115 */
116 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
117
118 /* add property to system-property vector */
119 void attach_property(char *name, char *value);
120
121 /* correct vftbl-entries of javastring-hash */
122 void stringtable_update();
123
124 /* throw classnotfoundexcetion */
125 void throw_classnotfoundexception();
126
127 /* throw classnotfoundexcetion with description*/
128 void throw_classnotfoundexception2(utf* classname);
129
130 /* throw linkageerror with description*/
131 void throw_linkageerror2(utf* classname);
132
133
134 /* make utf symbol from javastring */
135 utf *javastring_toutf(struct java_lang_String *string, bool isclassname);
136
137 /* make utf symbol from u2 array */
138 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
139
140 /* determine utf length in bytes of a u2 array */
141 u4 u2_utflength(u2 *text, u4 u2_length);
142
143 /* create systemclassloader object and initialize its instance fields  */
144 void init_systemclassloader();
145
146 /* search 'classinfo'-structure for a field with the specified name */
147 fieldinfo *class_findfield_approx(classinfo *c, utf *name);
148 s4 class_findfield_index_approx(classinfo *c, utf *name);
149
150 /* creates a new javastring with the text of the utf-symbol */
151 java_objectheader *literalstring_new(utf *u);
152
153 /* creates a new javastring with the text of the u2-array */
154 java_objectheader *literalstring_u2(java_chararray *a, u4 length, bool copymode);
155
156 /* dispose a javastring */
157 void literalstring_free(java_objectheader*);
158
159 void systemclassloader_addlibname(java_objectheader *o);
160 void systemclassloader_addlibrary(java_objectheader *o);
161
162 void copy_vftbl(vftbl **dest, vftbl *src);
163
164 utf *create_methodsig(java_objectarray* types, char *retType);
165 classinfo *get_type(char **utf_ptr,char *desc_end, bool skip);
166 java_objectarray* get_parametertypes(methodinfo *m);
167 classinfo *get_returntype(methodinfo *m);
168
169 #endif /* _NATIVE_H */
170
171
172 /*
173  * These are local overrides for various environment variables in Emacs.
174  * Please do not remove this and leave it at the end of the file, where
175  * Emacs will automagically detect them.
176  * ---------------------------------------------------------------------
177  * Local variables:
178  * mode: c
179  * indent-tabs-mode: t
180  * c-basic-offset: 4
181  * tab-width: 4
182  * End:
183  */