removed "class" field in constant_FMIref
[cacao.git] / src / vm / class.h
1 /* src/vm/class.h - class related functions header
2
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
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: Christian Thalinger
28
29    Changes:
30
31    $Id: class.h 2186 2005-04-02 00:43:25Z edwin $
32
33 */
34
35
36 #ifndef _CLASS_H
37 #define _CLASS_H
38
39 /* forward typedefs ***********************************************************/
40
41 typedef struct innerclassinfo innerclassinfo;
42 typedef struct extra_classref extra_classref;
43
44 #include "config.h"
45 #include "toolbox/list.h"
46 #include "vm/global.h"
47 #include "vm/utf8.h"
48 #include "vm/references.h"
49 #include "vm/field.h"
50 #include "vm/linker.h"
51 #include "vm/tables.h"
52 #include "vm/jit/inline/sets.h"
53
54 /* classinfo ******************************************************************/
55
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;
62
63         s4 initializing_thread;       /* gnu classpath                            */
64         s4 erroneous_state;           /* gnu classpath                            */
65         struct gnu_classpath_RawData* vmData; /* gnu classpath                    */
66
67         s4          flags;            /* ACC flags                                */
68         utf        *name;             /* class name                               */
69
70         s4          cpcount;          /* number of entries in constant pool       */
71         u1         *cptags;           /* constant pool tags                       */
72         voidptr    *cpinfos;          /* pointer to constant pool info structures */
73
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                       */
79
80         classref_or_classinfo super;  /* super class                              */
81         classinfo  *sub;              /* sub class pointer                        */
82         classinfo  *nextsub;          /* pointer to next class in sub class list  */
83
84         s4          interfacescount;  /* number of interfaces                     */
85         classref_or_classinfo *interfaces; /* superinterfaces                     */
86
87         s4          fieldscount;      /* number of fields                         */
88         fieldinfo  *fields;           /* field table                              */
89
90         s4          methodscount;     /* number of methods                        */
91         methodinfo *methods;          /* method table                             */
92
93         listnode    listnode;         /* linkage                                  */
94
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       */
100                                       /* (interfaces)                             */
101         s4          instancesize;     /* size of an instance of this class        */
102
103         vftbl_t    *vftbl;            /* pointer to virtual function table        */
104
105         methodinfo *finalizer;        /* finalizer method                         */
106
107         u2          innerclasscount;  /* number of inner classes                  */
108         innerclassinfo *innerclass;
109
110         classinfo  *hashlink;         /* link for external hash chain             */
111         bool        classvftbl;       /* has its own copy of the Class vtbl       */
112
113         s4          classUsed;        /* 0= not used 1 = used   CO-RT             */
114
115         classSetNode *impldBy;        /* interface class implemented by class set */
116                                       /*   Object class 's impldBy is list of all */
117                                       /*   interface classes used (RT & XTA only  */
118                                       /*     normally no list of interfaces used) */
119         utf        *packagename;      /* full name of the package                 */
120         utf        *sourcefile;       /* classfile name containing this class     */
121         java_objectheader *classloader; /* NULL for bootstrap classloader         */
122 };
123
124
125 /* innerclassinfo *************************************************************/
126
127 struct innerclassinfo {
128         classinfo *inner_class;       /* inner class pointer                      */
129         classinfo *outer_class;       /* outer class pointer                      */
130         utf       *name;              /* innerclass name                          */
131         s4         flags;             /* ACC flags                                */
132 };
133
134
135 /* extra_classref **************************************************************
136
137    for classrefs not occurring within descriptors
138
139 *******************************************************************************/
140
141 struct extra_classref {
142         extra_classref    *next;
143         constant_classref  classref;
144 };
145
146
147 /* global variables ***********************************************************/
148
149 extern hashtable class_hash;            /* hashtable for classes              */
150
151 extern list unlinkedclasses;   /* this is only used for eager class loading   */
152
153
154 /* frequently used classes ****************************************************/
155
156 /* important system classes */
157
158 extern classinfo *class_java_lang_Object;
159 extern classinfo *class_java_lang_Class;
160 extern classinfo *class_java_lang_ClassLoader;
161 extern classinfo *class_java_lang_Cloneable;
162 extern classinfo *class_java_lang_SecurityManager;
163 extern classinfo *class_java_lang_String;
164 extern classinfo *class_java_lang_System;
165 extern classinfo *class_java_io_Serializable;
166
167
168 /* system exception classes required in cacao */
169
170 extern classinfo *class_java_lang_Throwable;
171 extern classinfo *class_java_lang_VMThrowable;
172 extern classinfo *class_java_lang_Exception;
173 extern classinfo *class_java_lang_Error;
174 extern classinfo *class_java_lang_OutOfMemoryError;
175 extern classinfo *class_java_lang_NoClassDefFoundError;
176
177
178 extern classinfo *class_java_lang_Void;
179 extern classinfo *class_java_lang_Boolean;
180 extern classinfo *class_java_lang_Byte;
181 extern classinfo *class_java_lang_Character;
182 extern classinfo *class_java_lang_Short;
183 extern classinfo *class_java_lang_Integer;
184 extern classinfo *class_java_lang_Long;
185 extern classinfo *class_java_lang_Float;
186 extern classinfo *class_java_lang_Double;
187
188
189 /* some classes which may be used more often */
190
191 extern classinfo *class_java_util_Vector;
192
193
194 /* pseudo classes for the type checker ****************************************/
195
196 /*
197  * pseudo_class_Arraystub
198  *     (extends Object implements Cloneable, java.io.Serializable)
199  *
200  *     If two arrays of incompatible component types are merged,
201  *     the resulting reference has no accessible components.
202  *     The result does, however, implement the interfaces Cloneable
203  *     and java.io.Serializable. This pseudo class is used internally
204  *     to represent such results. (They are *not* considered arrays!)
205  *
206  * pseudo_class_Null
207  *
208  *     This pseudo class is used internally to represent the
209  *     null type.
210  *
211  * pseudo_class_New
212  *
213  *     This pseudo class is used internally to represent the
214  *     the 'uninitialized object' type.
215  */
216
217 extern classinfo *pseudo_class_Arraystub;
218 extern classinfo *pseudo_class_Null;
219 extern classinfo *pseudo_class_New;
220
221
222 /* function prototypes ********************************************************/
223
224 void class_init_foo(void);
225
226 /* search for class and create it if not found */
227 classinfo *class_new(utf *u);
228
229 /* without locking (caller already holding lock*/
230 classinfo *class_new_intern(utf *u);
231
232 /* search for class in classtable */
233 classinfo *class_get(utf *u);
234
235 /* remove class from classtable */
236 bool class_remove(classinfo *c);
237
238 /* frees all resources used by the class */
239 void class_free(classinfo *);
240
241 /* return an array class with the given component class */
242 classinfo *class_array_of(classinfo *component);
243
244 /* return an array class with the given dimension and element class */
245 classinfo *class_multiarray_of(s4 dim, classinfo *element);
246
247 /* return a classref for the given class name */
248 /* (does a linear search!)                    */
249 constant_classref *class_lookup_classref(classinfo *cls,utf *name);
250
251 /* return a classref for the given class name */
252 /* (does a linear search!)                    */
253 constant_classref *class_get_classref(classinfo *cls,utf *name);
254
255 /* return a classref for an array with the given dimension of with the */
256 /* given component type */
257 constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref);
258
259 /* return a classref for the component type of the given array type */
260 constant_classref *class_get_classref_component_of(constant_classref *ref);
261
262 #endif /* _CLASS_H */
263
264
265 /*
266  * These are local overrides for various environment variables in Emacs.
267  * Please do not remove this and leave it at the end of the file, where
268  * Emacs will automagically detect them.
269  * ---------------------------------------------------------------------
270  * Local variables:
271  * mode: c
272  * indent-tabs-mode: t
273  * c-basic-offset: 4
274  * tab-width: 4
275  * End:
276  */