1 /* loader.h - class loader header
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
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 1296 2004-07-10 17:02:15Z stefan $
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 */
53 /* export variables */
60 /* references to some system classes ******************************************/
62 extern classinfo *class_java_lang_Object;
63 extern classinfo *class_java_lang_String;
64 extern classinfo *class_java_lang_Cloneable;
65 extern classinfo *class_java_io_Serializable;
66 extern utf *utf_fillInStackTrace_name;
67 extern utf *utf_fillInStackTrace_desc;
69 /* pseudo classes for the type checker ****************************************/
72 * pseudo_class_Arraystub
73 * (extends Object implements Cloneable, java.io.Serializable)
75 * If two arrays of incompatible component types are merged,
76 * the resulting reference has no accessible components.
77 * The result does, however, implement the interfaces Cloneable
78 * and java.io.Serializable. This pseudo class is used internally
79 * to represent such results. (They are *not* considered arrays!)
83 * This pseudo class is used internally to represent the
88 * This pseudo class is used internally to represent the
89 * the 'uninitialized object' type.
92 extern classinfo *pseudo_class_Arraystub;
93 extern classinfo *pseudo_class_Null;
94 extern classinfo *pseudo_class_New;
95 extern vftbl_t *pseudo_class_Arraystub_vftbl;
97 extern utf *array_packagename;
100 /************************ prototypes ******************************************/
102 /* initialize laoder, load important systemclasses */
105 void suck_init(char *cpath);
106 void create_all_classes();
107 void suck_stop(classbuffer *cb);
112 void loader_compute_subclasses();
114 /* retrieve constantpool element */
115 voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
117 /* determine type of a constantpool element */
118 u4 class_constanttype(classinfo *class, u4 pos);
120 s4 class_findmethodIndex(classinfo *c, utf *name, utf *desc);
122 /* search class for a field */
123 fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
124 fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer, bool except);
126 /* search for a method with a specified name and descriptor */
127 methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
128 methodinfo *class_fetchmethod(classinfo *c, utf *name, utf *desc);
129 methodinfo *class_findmethod_w(classinfo *c, utf *name, utf *desc, char*);
130 methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
131 methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool except);
132 methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool except);
134 /* search for a method with specified name and arguments (returntype ignored) */
135 methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc);
136 methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *dest);
138 bool class_issubclass(classinfo *sub, classinfo *super);
140 /* call initializer of class */
141 classinfo *class_init(classinfo *c);
143 void class_showconstanti(classinfo *c, int ii);
146 void class_showmethods(classinfo *c);
147 void class_showconstantpool(classinfo *c);
148 void print_arraydescriptor(FILE *file, arraydescriptor *desc);
150 /* return the primitive class inidicated by the given signature character */
151 classinfo *class_primitive_from_sig(char sig);
154 /* return the class indicated by the given descriptor */
155 /* (see loader.c for documentation) */
156 #define CLASSLOAD_NEW 0 /* default */
157 #define CLASSLOAD_LOAD 0x0001
158 #define CLASSLOAD_SKIP 0x0002
159 #define CLASSLOAD_PANIC 0 /* default */
160 #define CLASSLOAD_NOPANIC 0x0010
161 #define CLASSLOAD_PRIMITIVE 0 /* default */
162 #define CLASSLOAD_NULLPRIMITIVE 0x0020
163 #define CLASSLOAD_VOID 0 /* default */
164 #define CLASSLOAD_NOVOID 0x0040
165 #define CLASSLOAD_NOCHECKEND 0 /* default */
166 #define CLASSLOAD_CHECKEND 0x1000
168 classinfo *class_from_descriptor(char *utf_ptr,char *end_ptr,char **next,int mode);
169 int type_from_descriptor(classinfo **cls,char *utf_ptr,char *end_ptr,char **next,int mode);
171 /* (used by class_new, don't use directly) */
172 void class_new_array(classinfo *c);
174 classinfo *class_load(classinfo *c);
175 classinfo *class_load_intern(classbuffer *cb);
176 classinfo *class_link(classinfo *c);
177 void class_free(classinfo *c);
179 void field_display(fieldinfo *f);
181 void method_display(methodinfo *m);
187 /******************************** CLASSPATH handling *******************/
188 #define CLASSPATH_MAXFILENAME 1000 /* maximum length of a filename */
189 #define CLASSPATH_PATH 0
190 #define CLASSPATH_ARCHIVE 1
192 typedef union classpath_info {
195 union classpath_info *next;
197 int pathlen; } filepath;
201 union classpath_info *next;
207 #endif /* _LOADER_H */
211 * These are local overrides for various environment variables in Emacs.
212 * Please do not remove this and leave it at the end of the file, where
213 * Emacs will automagically detect them.
214 * ---------------------------------------------------------------------
217 * indent-tabs-mode: t