X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvmcore%2Fclass.h;h=48ade646e805c60ce6febae28e23f11c0ed28145;hb=9f859ad50d3d5d98c185d40b86b2179bc4dc9aeb;hp=4d6c8531f04d0d1a6d694c689be621fe57e36c5f;hpb=94cdb8ded35be46114694462f2e2626d73074469;p=cacao.git diff --git a/src/vmcore/class.h b/src/vmcore/class.h index 4d6c8531f..48ade646e 100644 --- a/src/vmcore/class.h +++ b/src/vmcore/class.h @@ -22,8 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: class.h 7355 2007-02-14 10:57:32Z twisti $ - */ @@ -35,9 +33,13 @@ typedef struct classinfo classinfo; typedef struct innerclassinfo innerclassinfo; typedef struct extra_classref extra_classref; +typedef struct castinfo castinfo; #include "config.h" + +#include + #include "vm/types.h" #include "toolbox/list.h" @@ -76,12 +78,21 @@ typedef struct extra_classref extra_classref; /* 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 */ @@ -113,8 +124,6 @@ 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) */ @@ -127,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 */ }; @@ -165,10 +193,16 @@ struct extra_classref { }; -/* global variables ***********************************************************/ +/* castinfo *******************************************************************/ + +struct castinfo { + s4 super_baseval; + s4 super_diffval; + s4 sub_baseval; +}; -extern list unlinkedclasses; /* this is only used for eager class loading */ +/* global variables ***********************************************************/ /* frequently used classes ****************************************************/ @@ -187,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 */ @@ -207,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; @@ -268,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); @@ -328,6 +368,26 @@ methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classin methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception); 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 */