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 1088 2004-05-26 21:32:34Z twisti $
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;
68 /* pseudo classes for the type checker ****************************************/
71 * pseudo_class_Arraystub
72 * (extends Object implements Cloneable, java.io.Serializable)
74 * If two arrays of incompatible component types are merged,
75 * the resulting reference has no accessible components.
76 * The result does, however, implement the interfaces Cloneable
77 * and java.io.Serializable. This pseudo class is used internally
78 * to represent such results. (They are *not* considered arrays!)
82 * This pseudo class is used internally to represent the
87 * This pseudo class is used internally to represent the
88 * the 'uninitialized object' type.
91 extern classinfo *pseudo_class_Arraystub;
92 extern classinfo *pseudo_class_Null;
93 extern classinfo *pseudo_class_New;
94 extern vftbl *pseudo_class_Arraystub_vftbl;
96 extern utf *array_packagename;
99 /************************ prototypes ******************************************/
101 /* initialize laoder, load important systemclasses */
104 void suck_init(char *cpath);
105 void create_all_classes();
106 void suck_stop(classbuffer *cb);
111 void loader_compute_subclasses();
113 /* retrieve constantpool element */
114 voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
116 /* determine type of a constantpool element */
117 u4 class_constanttype(classinfo *class, u4 pos);
119 s4 class_findmethodIndex(classinfo *c, utf *name, utf *desc);
121 /* search class for a field */
122 fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
123 fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer, bool except);
125 /* search for a method with a specified name and descriptor */
126 methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
127 methodinfo *class_fetchmethod(classinfo *c, utf *name, utf *desc);
128 methodinfo *class_findmethod_w(classinfo *c, utf *name, utf *desc, char*);
129 methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
130 methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool except);
131 methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool except);
133 /* search for a method with specified name and arguments (returntype ignored) */
134 methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc);
135 methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *dest);
137 bool class_issubclass(classinfo *sub, classinfo *super);
139 /* call initializer of class */
140 classinfo *class_init(classinfo *c);
142 void class_showconstanti(classinfo *c, int ii);
145 void class_showmethods(classinfo *c);
146 void class_showconstantpool(classinfo *c);
147 void print_arraydescriptor(FILE *file, arraydescriptor *desc);
149 /* return the primitive class inidicated by the given signature character */
150 classinfo *class_primitive_from_sig(char sig);
153 /* return the class indicated by the given descriptor */
154 /* (see loader.c for documentation) */
155 #define CLASSLOAD_NEW 0 /* default */
156 #define CLASSLOAD_LOAD 0x0001
157 #define CLASSLOAD_SKIP 0x0002
158 #define CLASSLOAD_PANIC 0 /* default */
159 #define CLASSLOAD_NOPANIC 0x0010
160 #define CLASSLOAD_PRIMITIVE 0 /* default */
161 #define CLASSLOAD_NULLPRIMITIVE 0x0020
162 #define CLASSLOAD_VOID 0 /* default */
163 #define CLASSLOAD_NOVOID 0x0040
164 #define CLASSLOAD_NOCHECKEND 0 /* default */
165 #define CLASSLOAD_CHECKEND 0x1000
167 classinfo *class_from_descriptor(char *utf_ptr,char *end_ptr,char **next,int mode);
168 int type_from_descriptor(classinfo **cls,char *utf_ptr,char *end_ptr,char **next,int mode);
170 /* (used by class_new, don't use directly) */
171 void class_new_array(classinfo *c);
173 classinfo *class_load(classinfo *c);
174 classinfo *class_load_intern(classbuffer *cb);
175 classinfo *class_link(classinfo *c);
177 void field_display(fieldinfo *f);
179 void method_display(methodinfo *m);
185 /******************************** CLASSPATH handling *******************/
186 #define CLASSPATH_MAXFILENAME 1000 /* maximum length of a filename */
187 #define CLASSPATH_PATH 0
188 #define CLASSPATH_ARCHIVE 1
190 typedef union classpath_info {
193 union classpath_info *next;
195 int pathlen; } filepath;
199 union classpath_info *next;
205 #endif /* _LOADER_H */
209 * These are local overrides for various environment variables in Emacs.
210 * Please do not remove this and leave it at the end of the file, where
211 * Emacs will automagically detect them.
212 * ---------------------------------------------------------------------
215 * indent-tabs-mode: t