* src/vm/jit/alpha/codegen.c (codegen): Use lock_monitor_enter/exit
[cacao.git] / src / vm / class.h
index 8ff041a4defbd9993daacc2aad99e20ec598742f..c5b4fafa21cee91ec7afb7226f8ed982ec4a5df3 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/class.h - class related functions header
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Christian Thalinger
 
    Changes:
 
-   $Id: class.h 3292 2005-09-28 10:36:34Z twisti $
+   $Id: class.h 5088 2006-07-08 20:16:05Z twisti $
 
 */
 
@@ -45,28 +45,38 @@ typedef struct extra_classref extra_classref;
 #include "config.h"
 #include "vm/types.h"
 
+#include "vm/global.h"                  /* define java_objectheader for j.l.C */
+#include "native/include/java_lang_Class.h"
+
 #include "toolbox/list.h"
-#include "vm/global.h"
-#include "vm/utf8.h"
-#include "vm/references.h"
 #include "vm/field.h"
 #include "vm/linker.h"
-#include "vm/tables.h"
-#include "vm/jit/inline/sets.h"
+#include "vm/method.h"
+#include "vm/references.h"
+#include "vm/utf8.h"
+
+
+/* class state defines ********************************************************/
+
+#define CLASS_LOADING         0x0001
+#define CLASS_LOADED          0x0002
+#define CLASS_LINKING         0x0004
+#define CLASS_LINKED          0x0008
+#define CLASS_INITIALIZING    0x0010
+#define CLASS_INITIALIZED     0x0020
+#define CLASS_ERROR           0x0040
+
+
+/* some macros ****************************************************************/
+
+#define CLASS_IS_OR_ALMOST_INITIALIZED(c) \
+    (((c)->state & CLASS_INITIALIZING) || ((c)->state & CLASS_INITIALIZED))
 
 
 /* classinfo ******************************************************************/
 
 struct classinfo {                /* class structure                          */
-       java_objectheader header;     /* classes are also objects                 */
-       java_objectarray* signers;
-       struct java_security_ProtectionDomain* pd;
-       struct java_lang_VMClass* vmClass;
-       struct java_lang_reflect_Constructor* constructor;
-
-       s4 initializing_thread;       /* gnu classpath                            */
-       s4 erroneous_state;           /* gnu classpath                            */
-       struct gnu_classpath_RawData* vmData; /* gnu classpath                    */
+       java_lang_Class object;       /* classinfos are also j.l.C objects        */
 
        s4          flags;            /* ACC flags                                */
        utf        *name;             /* class name                               */
@@ -96,10 +106,7 @@ struct classinfo {                /* class structure                          */
 
        listnode    listnode;         /* linkage                                  */
 
-       bool        initialized;      /* true, if class already initialized       */
-       bool        initializing;     /* flag for the compiler                    */
-       bool        loaded;           /* true, if class already loaded            */
-       bool        linked;           /* true, if class already linked            */
+       s4          state;            /* current class state                      */
        s4          index;            /* hierarchy depth (classes) or index       */
                                      /* (interfaces)                             */
        s4          instancesize;     /* size of an instance of this class        */
@@ -111,14 +118,6 @@ struct classinfo {                /* class structure                          */
        u2          innerclasscount;  /* number of inner classes                  */
        innerclassinfo *innerclass;
 
-       bool        classvftbl;       /* has its own copy of the Class vtbl       */
-
-       s4          classUsed;        /* 0= not used 1 = used   CO-RT             */
-
-       classSetNode *impldBy;        /* interface class implemented by class set */
-                                     /*   Object class 's impldBy is list of all */
-                                     /*   interface classes used (RT & XTA only  */
-                                     /*     normally no list of interfaces used) */
        utf        *packagename;      /* full name of the package                 */
        utf        *sourcefile;       /* classfile name containing this class     */
        java_objectheader *classloader; /* NULL for bootstrap classloader         */
@@ -174,11 +173,17 @@ extern classinfo *class_java_io_Serializable;
 extern classinfo *class_java_lang_Throwable;
 extern classinfo *class_java_lang_VMThrowable;
 extern classinfo *class_java_lang_Error;
+extern classinfo *class_java_lang_AbstractMethodError;
+extern classinfo *class_java_lang_LinkageError;
 extern classinfo *class_java_lang_NoClassDefFoundError;
+extern classinfo *class_java_lang_NoSuchMethodError;
 extern classinfo *class_java_lang_OutOfMemoryError;
 
 extern classinfo *class_java_lang_Exception;
+extern classinfo *class_java_lang_ClassCastException;
 extern classinfo *class_java_lang_ClassNotFoundException;
+extern classinfo *class_java_lang_IllegalArgumentException;
+extern classinfo *class_java_lang_IllegalMonitorStateException;
 
 
 extern classinfo *class_java_lang_Void;
@@ -192,6 +197,11 @@ extern classinfo *class_java_lang_Float;
 extern classinfo *class_java_lang_Double;
 
 
+/* some runtime exception */
+
+extern classinfo *class_java_lang_NullPointerException;
+
+
 /* some classes which may be used more often */
 
 extern classinfo *class_java_lang_StackTraceElement;
@@ -237,6 +247,9 @@ extern classinfo *pseudo_class_New;
 /* create a new classinfo struct */
 classinfo *class_create_classinfo(utf *u);
 
+/* postset's the header.vftbl */
+void class_postset_header_vftbl(void);
+
 /* set the package name after the name has been set */
 void class_set_packagename(classinfo *c);
 
@@ -272,6 +285,38 @@ constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *re
 /* return a classref for the component type of the given array type */
 constant_classref *class_get_classref_component_of(constant_classref *ref);
 
+/* get a class' field by name and descriptor */
+fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
+
+/* search 'classinfo'-structure for a field with the specified name */
+fieldinfo *class_findfield_by_name(classinfo *c, utf *name);
+s4 class_findfield_index_by_name(classinfo *c, utf *name);
+
+/* search class for a field */
+fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer, bool throwexception);
+
+/* search for a method with a specified name and descriptor */
+methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
+methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
+methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
+methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
+
+bool class_issubclass(classinfo *sub, classinfo *super);
+
+/* some debugging functions */
+
+#if !defined(NDEBUG)
+void class_printflags(classinfo *c);
+void class_print(classinfo *c);
+void class_println(classinfo *c);
+void class_classref_print(constant_classref *cr);
+void class_classref_println(constant_classref *cr);
+#endif
+
+/* debug purposes */
+void class_showmethods(classinfo *c);
+void class_showconstantpool(classinfo *c);
+
 #endif /* _CLASS_H */