1 /* vm/loader.h - class loader header
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
8 This file is part of CACAO.
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.
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.
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
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
29 $Id: loader.h 2062 2005-03-23 11:16:45Z twisti $
39 # include "vm/unzip.h"
43 /* datastruture from a classfile */
45 typedef struct classbuffer {
46 classinfo *class; /* pointer to classinfo structure */
47 u1 *data; /* pointer to byte code */
48 s4 size; /* size of the byte code */
49 u1 *pos; /* current read position */
54 /* classpath_info *************************************************************/
56 #define CLASSPATH_PATH 0
57 #define CLASSPATH_ARCHIVE 1
59 typedef struct classpath_info classpath_info;
61 struct classpath_info {
62 #if defined(USE_THREADS)
63 /* Required for monitor locking on zip/jar files. */
64 java_objectheader header;
69 struct java_security_ProtectionDomain *pd;
77 /* export variables */
79 #if defined(USE_THREADS)
83 extern classpath_info *classpath_entries;
85 /* pseudo classes for the type checker ****************************************/
88 * pseudo_class_Arraystub
89 * (extends Object implements Cloneable, java.io.Serializable)
91 * If two arrays of incompatible component types are merged,
92 * the resulting reference has no accessible components.
93 * The result does, however, implement the interfaces Cloneable
94 * and java.io.Serializable. This pseudo class is used internally
95 * to represent such results. (They are *not* considered arrays!)
99 * This pseudo class is used internally to represent the
104 * This pseudo class is used internally to represent the
105 * the 'uninitialized object' type.
108 extern classinfo *pseudo_class_Arraystub;
109 extern classinfo *pseudo_class_Null;
110 extern classinfo *pseudo_class_New;
111 extern vftbl_t *pseudo_class_Arraystub_vftbl;
113 extern utf *array_packagename;
116 /************************ prototypes ******************************************/
118 /* initialize loader, load important systemclasses */
119 bool loader_init(u1 *stackbottom);
121 void suck_init(char *cpath);
122 void create_all_classes(void);
123 void suck_stop(classbuffer *cb);
126 void loader_close(void);
128 void loader_compute_subclasses(classinfo *c);
130 /* retrieve constantpool element */
131 voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
133 /* determine type of a constantpool element */
134 u4 class_constanttype(classinfo *class, u4 pos);
136 s4 class_findmethodIndex(classinfo *c, utf *name, utf *desc);
138 /* search class for a field */
139 fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
140 fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer, bool except);
142 /* search for a method with a specified name and descriptor */
143 methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
144 methodinfo *class_fetchmethod(classinfo *c, utf *name, utf *desc);
145 methodinfo *class_findmethod_w(classinfo *c, utf *name, utf *desc, char*);
146 methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
147 methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool except);
148 methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool except);
150 /* search for a method with specified name and arguments (returntype ignored) */
151 methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc);
152 methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *dest);
154 bool class_issubclass(classinfo *sub, classinfo *super);
156 /* call initializer of class */
157 classinfo *class_init(classinfo *c);
159 void class_showconstanti(classinfo *c, int ii);
162 void class_showmethods(classinfo *c);
163 void class_showconstantpool(classinfo *c);
164 void print_arraydescriptor(FILE *file, arraydescriptor *desc);
166 /* return the primitive class inidicated by the given signature character */
167 classinfo *class_primitive_from_sig(char sig);
170 /* return the class indicated by the given descriptor */
171 /* (see loader.c for documentation) */
172 #define CLASSLOAD_NEW 0 /* default */
173 #define CLASSLOAD_LOAD 0x0001
174 #define CLASSLOAD_SKIP 0x0002
175 #define CLASSLOAD_PANIC 0 /* default */
176 #define CLASSLOAD_NOPANIC 0x0010
177 #define CLASSLOAD_PRIMITIVE 0 /* default */
178 #define CLASSLOAD_NULLPRIMITIVE 0x0020
179 #define CLASSLOAD_VOID 0 /* default */
180 #define CLASSLOAD_NOVOID 0x0040
181 #define CLASSLOAD_NOCHECKEND 0 /* default */
182 #define CLASSLOAD_CHECKEND 0x1000
184 classinfo *class_from_descriptor(char *utf_ptr,char *end_ptr,char **next,int mode);
185 int type_from_descriptor(classinfo **cls,char *utf_ptr,char *end_ptr,char **next,int mode);
187 /* (used by class_new, don't use directly) */
188 void class_new_array(classinfo *c);
190 #define LAZYLOADING(class) { \
191 if (!class->loaded) \
192 if (!class_load(class)) \
194 if (!class->linked) \
195 if (!class_link(class)) \
200 #define LAZYLOADING1(class) { \
201 if (!class->loaded) \
202 if (!class_load(class)) \
204 if (!class->linked) \
205 if (!class_link(class)) \
209 classinfo *class_load(classinfo *c);
210 classinfo *class_load_intern(classbuffer *cb);
211 classinfo *class_link(classinfo *c);
212 void class_free(classinfo *c);
214 void field_display(fieldinfo *f);
216 void method_display(methodinfo *m);
217 void method_display_w_class(methodinfo *m);
219 utf* clinit_desc(void);
220 utf* clinit_name(void);
222 #endif /* _LOADER_H */
226 * These are local overrides for various environment variables in Emacs.
227 * Please do not remove this and leave it at the end of the file, where
228 * Emacs will automagically detect them.
229 * ---------------------------------------------------------------------
232 * indent-tabs-mode: t