* Removed all Id tags.
[cacao.git] / src / vmcore / class.h
index 7ee2800a90827dcce59972e37f37bfa6d0cabe00..48ade646e805c60ce6febae28e23f11c0ed28145 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: class.h 7783 2007-04-20 13:28:27Z twisti $
-
 */
 
 
@@ -39,6 +37,9 @@ typedef struct castinfo       castinfo;
 
 
 #include "config.h"
+
+#include <stdint.h>
+
 #include "vm/types.h"
 
 #include "toolbox/list.h"
@@ -77,12 +78,21 @@ typedef struct castinfo       castinfo;
 /* classinfo ******************************************************************/
 
 /* We define this dummy structure of java_lang_Class so we can
-   bootstrap cacaoh without needing a java_lang_Class.h file.  If the
-   size is big enough, is checked during runtime in vm_create. */
+   bootstrap cacaoh without needing a java_lang_Class.h file.  Whether
+   the size of the dummy structure is big enough is checked during
+   runtime in vm_create. */
 
 typedef struct {
-       java_objectheader header;
-       ptrint            padding[4];
+       java_object_t      header;
+#if defined(WITH_CLASSPATH_GNU)
+       intptr_t           padding[4];
+#elif defined(WITH_CLASSPATH_SUN)
+       intptr_t           padding[19];
+#elif defined(WITH_CLASSPATH_CLDC1_1)
+       intptr_t           padding[3];
+#else
+# error unknown classpath configuration
+#endif
 } dummy_java_lang_Class;
 
 struct classinfo {                /* class structure                          */
@@ -114,8 +124,6 @@ struct classinfo {                /* class structure                          */
        s4          methodscount;     /* number of methods                        */
        methodinfo *methods;          /* method table                             */
 
-       listnode_t  listnode;         /* linkage                                  */
-
        s4          state;            /* current class state                      */
        s4          index;            /* hierarchy depth (classes) or index       */
                                      /* (interfaces)                             */
@@ -128,19 +136,38 @@ struct classinfo {                /* class structure                          */
        u2          innerclasscount;  /* number of inner classes                  */
        innerclassinfo *innerclass;
 
-#if defined(ENABLE_JAVASE)
+       classref_or_classinfo  declaringclass;
        classref_or_classinfo  enclosingclass;  /* enclosing class                */
        constant_nameandtype  *enclosingmethod; /* enclosing method               */
-#endif
 
        utf        *packagename;      /* full name of the package                 */
        utf        *sourcefile;       /* SourceFile attribute                     */
 #if defined(ENABLE_JAVASE)
        utf        *signature;        /* Signature attribute                      */
-       s4            runtimevisibleannotationscount;
-       annotation_t *runtimevisibleannotations;
+#if defined(ENABLE_ANNOTATIONS)
+        /* all the anntation attributes are NULL (and not a zero length array)
+          if there is nothing */
+       annotation_bytearray_t  *annotations; /* annotations of this class        */
+       
+       annotation_bytearrays_t *method_annotations; /* array of annotations for  */
+                                     /* the methods                              */
+       annotation_bytearrays_t *method_parameterannotations; /* array of         */
+                                     /* parameter annotations for the methods    */
+       annotation_bytearrays_t *method_annotationdefaults; /* array for          */
+                                     /* annotation default values for the        */
+                                     /* methods                                  */
+
+       annotation_bytearrays_t *field_annotations; /* array of annotations for   */
+                                     /* the fields                               */
+#endif
+#endif
+       classloader *classloader;       /* NULL for bootstrap classloader         */
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_CLASSPATH_SUN)
+       java_object_t *protectiondomain;
+# endif
 #endif
-       java_objectheader *classloader; /* NULL for bootstrap classloader         */
 };
 
 
@@ -177,9 +204,6 @@ struct castinfo {
 
 /* global variables ***********************************************************/
 
-extern list_t unlinkedclasses; /* this is only used for eager class loading   */
-
-
 /* frequently used classes ****************************************************/
 
 /* important system classes */
@@ -197,6 +221,9 @@ extern classinfo *class_java_lang_VMSystem;
 extern classinfo *class_java_lang_VMThread;
 extern classinfo *class_java_io_Serializable;
 
+#if defined(WITH_CLASSPATH_SUN)
+extern classinfo *class_sun_reflect_MagicAccessorImpl;
+#endif
 
 /* system exception classes required in cacao */
 
@@ -217,6 +244,13 @@ extern classinfo *class_java_lang_ClassNotFoundException;
 
 #if defined(ENABLE_JAVASE)
 extern classinfo *class_java_lang_Void;
+
+#if defined(ENABLE_ANNOTATIONS)
+extern classinfo *class_sun_reflect_ConstantPool;
+#if defined(WITH_CLASSPATH_GNU)
+extern classinfo *class_sun_reflect_annotation_AnnotationParser;
+#endif
+#endif
 #endif
 
 extern classinfo *class_java_lang_Boolean;
@@ -278,16 +312,12 @@ extern classinfo *pseudo_class_New;
 
 /* function prototypes ********************************************************/
 
-/* create a new classinfo struct */
 classinfo *class_create_classinfo(utf *u);
+void       class_postset_header_vftbl(void);
+classinfo *class_define(utf *name, classloader *cl, int32_t length, const uint8_t *data, java_handle_t *pd);
+void       class_set_packagename(classinfo *c);
 
-/* 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);
-
-bool class_load_attributes(classbuffer *cb);
+bool       class_load_attributes(classbuffer *cb);
 
 /* retrieve constantpool element */
 voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
@@ -340,6 +370,25 @@ methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, cla
 bool class_issubclass(classinfo *sub, classinfo *super);
 bool class_isanysubclass(classinfo *sub, classinfo *super);
 
+bool                       class_is_primitive(classinfo *c);
+bool                       class_is_anonymousclass(classinfo *c);
+bool                       class_is_array(classinfo *c);
+bool                       class_is_interface(classinfo *c);
+bool                       class_is_localclass(classinfo *c);
+bool                       class_is_memberclass(classinfo *c);
+
+classinfo                 *class_get_superclass(classinfo *c);
+classinfo                 *class_get_componenttype(classinfo *c);
+java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly);
+classinfo                 *class_get_declaringclass(classinfo *c);
+classinfo                 *class_get_enclosingclass(classinfo *c);
+java_handle_objectarray_t *class_get_interfaces(classinfo *c);
+java_handle_bytearray_t   *class_get_annotations(classinfo *c);
+
+#if defined(ENABLE_JAVASE)
+utf                       *class_get_signature(classinfo *c);
+#endif
+
 /* some debugging functions */
 
 #if !defined(NDEBUG)