1 /* src/vm/class.h - class related functions 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: Christian Thalinger
31 $Id: class.h 2195 2005-04-03 16:53:16Z edwin $
39 /* forward typedefs ***********************************************************/
41 typedef struct innerclassinfo innerclassinfo;
42 typedef struct extra_classref extra_classref;
45 #include "toolbox/list.h"
46 #include "vm/global.h"
48 #include "vm/references.h"
50 #include "vm/linker.h"
51 #include "vm/tables.h"
52 #include "vm/jit/inline/sets.h"
54 /* classinfo ******************************************************************/
56 struct classinfo { /* class structure */
57 java_objectheader header; /* classes are also objects */
58 java_objectarray* signers;
59 struct java_security_ProtectionDomain* pd;
60 struct java_lang_VMClass* vmClass;
61 struct java_lang_reflect_Constructor* constructor;
63 s4 initializing_thread; /* gnu classpath */
64 s4 erroneous_state; /* gnu classpath */
65 struct gnu_classpath_RawData* vmData; /* gnu classpath */
67 s4 flags; /* ACC flags */
68 utf *name; /* class name */
70 s4 cpcount; /* number of entries in constant pool */
71 u1 *cptags; /* constant pool tags */
72 voidptr *cpinfos; /* pointer to constant pool info structures */
74 s4 classrefcount; /* number of symbolic class references */
75 constant_classref *classrefs; /* table of symbolic class references */
76 extra_classref *extclassrefs; /* additional classrefs */
77 s4 parseddescsize; /* size of the parsed descriptors block */
78 u1 *parseddescs; /* parsed descriptors */
80 classref_or_classinfo super; /* super class */
81 classinfo *sub; /* sub class pointer */
82 classinfo *nextsub; /* pointer to next class in sub class list */
84 s4 interfacescount; /* number of interfaces */
85 classref_or_classinfo *interfaces; /* superinterfaces */
87 s4 fieldscount; /* number of fields */
88 fieldinfo *fields; /* field table */
90 s4 methodscount; /* number of methods */
91 methodinfo *methods; /* method table */
93 listnode listnode; /* linkage */
95 bool initialized; /* true, if class already initialized */
96 bool initializing; /* flag for the compiler */
97 bool loaded; /* true, if class already loaded */
98 bool linked; /* true, if class already linked */
99 s4 index; /* hierarchy depth (classes) or index */
101 s4 instancesize; /* size of an instance of this class */
103 vftbl_t *vftbl; /* pointer to virtual function table */
105 methodinfo *finalizer; /* finalizer method */
107 u2 innerclasscount; /* number of inner classes */
108 innerclassinfo *innerclass;
110 bool classvftbl; /* has its own copy of the Class vtbl */
112 s4 classUsed; /* 0= not used 1 = used CO-RT */
114 classSetNode *impldBy; /* interface class implemented by class set */
115 /* Object class 's impldBy is list of all */
116 /* interface classes used (RT & XTA only */
117 /* normally no list of interfaces used) */
118 utf *packagename; /* full name of the package */
119 utf *sourcefile; /* classfile name containing this class */
120 java_objectheader *classloader; /* NULL for bootstrap classloader */
124 /* innerclassinfo *************************************************************/
126 struct innerclassinfo {
127 classref_or_classinfo inner_class; /* inner class pointer */
128 classref_or_classinfo outer_class; /* outer class pointer */
129 utf *name; /* innerclass name */
130 s4 flags; /* ACC flags */
134 /* extra_classref **************************************************************
136 for classrefs not occurring within descriptors
138 *******************************************************************************/
140 struct extra_classref {
141 extra_classref *next;
142 constant_classref classref;
146 /* global variables ***********************************************************/
148 extern list unlinkedclasses; /* this is only used for eager class loading */
151 /* frequently used classes ****************************************************/
153 /* important system classes */
155 extern classinfo *class_java_lang_Object;
156 extern classinfo *class_java_lang_Class;
157 extern classinfo *class_java_lang_ClassLoader;
158 extern classinfo *class_java_lang_Cloneable;
159 extern classinfo *class_java_lang_SecurityManager;
160 extern classinfo *class_java_lang_String;
161 extern classinfo *class_java_lang_System;
162 extern classinfo *class_java_io_Serializable;
165 /* system exception classes required in cacao */
167 extern classinfo *class_java_lang_Throwable;
168 extern classinfo *class_java_lang_VMThrowable;
169 extern classinfo *class_java_lang_Exception;
170 extern classinfo *class_java_lang_Error;
171 extern classinfo *class_java_lang_OutOfMemoryError;
172 extern classinfo *class_java_lang_NoClassDefFoundError;
175 extern classinfo *class_java_lang_Void;
176 extern classinfo *class_java_lang_Boolean;
177 extern classinfo *class_java_lang_Byte;
178 extern classinfo *class_java_lang_Character;
179 extern classinfo *class_java_lang_Short;
180 extern classinfo *class_java_lang_Integer;
181 extern classinfo *class_java_lang_Long;
182 extern classinfo *class_java_lang_Float;
183 extern classinfo *class_java_lang_Double;
186 /* some classes which may be used more often */
188 extern classinfo *class_java_util_Vector;
191 /* pseudo classes for the type checker ****************************************/
194 * pseudo_class_Arraystub
195 * (extends Object implements Cloneable, java.io.Serializable)
197 * If two arrays of incompatible component types are merged,
198 * the resulting reference has no accessible components.
199 * The result does, however, implement the interfaces Cloneable
200 * and java.io.Serializable. This pseudo class is used internally
201 * to represent such results. (They are *not* considered arrays!)
205 * This pseudo class is used internally to represent the
210 * This pseudo class is used internally to represent the
211 * the 'uninitialized object' type.
214 extern classinfo *pseudo_class_Arraystub;
215 extern classinfo *pseudo_class_Null;
216 extern classinfo *pseudo_class_New;
219 /* function prototypes ********************************************************/
221 /* create a new classinfo struct */
222 classinfo *create_classinfo(utf *u);
224 /* frees all resources used by the class */
225 void class_free(classinfo *);
227 /* return an array class with the given component class */
228 classinfo *class_array_of(classinfo *component,bool link);
230 /* return an array class with the given dimension and element class */
231 classinfo *class_multiarray_of(s4 dim, classinfo *element,bool link);
233 /* return a classref for the given class name */
234 /* (does a linear search!) */
235 constant_classref *class_lookup_classref(classinfo *cls,utf *name);
237 /* return a classref for the given class name */
238 /* (does a linear search!) */
239 constant_classref *class_get_classref(classinfo *cls,utf *name);
241 /* return a classref for an array with the given dimension of with the */
242 /* given component type */
243 constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref);
245 /* return a classref for the component type of the given array type */
246 constant_classref *class_get_classref_component_of(constant_classref *ref);
248 #endif /* _CLASS_H */
252 * These are local overrides for various environment variables in Emacs.
253 * Please do not remove this and leave it at the end of the file, where
254 * Emacs will automagically detect them.
255 * ---------------------------------------------------------------------
258 * indent-tabs-mode: t