Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.h 7563 2007-03-23 21:33:53Z twisti $
-
*/
#include "config.h"
+
+#include <stdint.h>
+
#include "vm/types.h"
#include "toolbox/list.h"
/* 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 */
s4 methodscount; /* number of methods */
methodinfo *methods; /* method table */
- listnode listnode; /* linkage */
-
s4 state; /* current class state */
s4 index; /* hierarchy depth (classes) or index */
/* (interfaces) */
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 */
};
/* global variables ***********************************************************/
-extern list unlinkedclasses; /* this is only used for eager class loading */
-
-
/* frequently used classes ****************************************************/
/* important system classes */
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 */
#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;
/* 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);
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)