* autogen.sh: Made executeable.
authorMathias Panzenboeck <e0427417@student.tuwien.ac.at>
Mon, 27 Aug 2007 20:18:02 +0000 (22:18 +0200)
committerMathias Panzenboeck <e0427417@student.tuwien.ac.at>
Mon, 27 Aug 2007 20:18:02 +0000 (22:18 +0200)
* src/cacaoh/dummy.c
(mm/memory.h): Added include.
(native/llni.h): Added include.
(array_objectarray_element_get): Added dummy implementation.
(array_objectarray_element_set): Added dummy implementation.
(array_length_get): Added dummy implementation.
(builtin_anewarray): Added dummy implementation using MNEW.
(builtin_newarray_byte): Added dummy implementation using MNEW.
(primitive_arrayclass_get_by_type): Added dummy implementation.

* src/mm/boehm-gc/autogen.sh: Made executeable.

* src/native/vm/gnu/java_lang_reflect_Constructor.c
(Java_java_lang_reflect_Constructor_declaredAnnotations):
Removed unused variable o.
(Java_java_lang_reflect_Constructor_getParameterAnnotations):
Removed unused variable o.

* src/native/vm/gnu/java_lang_reflect_Field.c
(Java_java_lang_reflect_Field_declaredAnnotations):
Removed unused variable o.

* src/native/vm/gnu/java_lang_reflect_Method.c
(Java_java_lang_reflect_Method_getDefaultValue):
Removed unused variable o.
(Java_java_lang_reflect_Method_declaredAnnotations):
Removed unused variable o.
(Java_java_lang_reflect_Method_getParameterAnnotations):
Removed unused variable o.

* src/native/vm/gnu/sun_reflect_ConstantPool.c
(_Jv_sun_reflect_ConstantPool_init): Removed usage of global string
utf_sun_reflect_ConstantPool.

* src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]:
Sorted includes.
(_Jv_java_lang_Class_getDeclaredAnnotations): Fixed comment.

* src/vmcore/annotation.c
(native/llni.h): Added include.
(vm/array.h): Added include.
(vm/builtin.h): Added include.
(vm/primitive.h): Added include.
(annotation_bytearray_new): Removed.
(annotation_bytearray_free): Removed.
(annotation_bytearrays_new): Removed.
(annotation_bytearrays_free): Removed.
(annotation_bytearrays_resize): Made static and now java_handle_objectarray_t
is used instead of my own array type.
(annotation_bytearrays_insert): Made static and now java_handle_objectarray_t
is used instead of my own array type.
(annotation_load_attribute_body):
Using java_handle_bytearray_t instead of my own array type.
(annotation_load_method_attribute_annotationdefault):
Using java_handle_bytearray_t and java_handle_objectarray_t instead of my own
array types.
(annotation_load_method_attribute_runtimevisibleparameterannotations):
Using java_handle_bytearray_t and java_handle_objectarray_t instead of my own
array types.
(annotation_load_method_attribute_runtimevisibleannotations):
Using java_handle_bytearray_t and java_handle_objectarray_t instead of my own
array types.
(annotation_load_field_attribute_runtimevisibleannotations):
Using java_handle_bytearray_t and java_handle_objectarray_t instead of my own
array types.

* src/vmcore/annotation.h
(annotation_bytearray_t): Removed.
(annotation_bytearrays_t): Removed.
(annotation_bytearray_new): Removed.
(annotation_bytearray_free): Removed.
(annotation_bytearrays_new): Removed.
(annotation_bytearrays_resize): Removed.
(annotation_bytearrays_insert): Removed.
(annotation_bytearrays_free): Removed.

* src/vmcore/class.c
(class_sun_reflect_annotation_AnnotationParser): Is only declared when
WITH_CLASSPATH_GNU is defined.
(class_free) [ENABLE_ANNOTATIONS]: Removed usage of
annotation_bytearray*_free() functions.
(class_get_annotations): Don't have to copy anything now, just return the
java_handle_bytearray_t.

* src/vmcore/class.h
(classinfo): Fixed comments.
(classinfo) [ENABLE_ANNOTATIONS]: Now using java_handle_bytearray_t and
java_handle_objectarray_t instead of my own array types.

* src/vmcore/loader.c
(loader_init): Removed usage of global string utf_sun_reflect_ConstantPool
and utf_sun_reflect_annotation_AnnotationParser.

* src/vmcore/field.c
(vm/array.h): Added include.
(field_get_annotations): Don't have to copy anything now, just return the
java_handle_bytearray_t.

* src/vmcore/method.c
(vm/array.h): Added include.
(method_get_annotations): Don't have to copy anything now, just return the
java_handle_bytearray_t.
(method_get_parameterannotations): Don't have to copy anything now, just return
the java_handle_bytearray_t.
(method_get_annotationdefault): Don't have to copy anything now, just return
the java_handle_bytearray_t.

* src/vmcore/utf8.c
(utf_sun_reflect_ConstantPool): Removed.
(utf_sun_reflect_annotation_AnnotationParser): Removed.

* src/vmcore/utf8.h
(utf_sun_reflect_ConstantPool): Removed.
(utf_sun_reflect_annotation_AnnotationParser): Removed.

17 files changed:
autogen.sh [changed mode: 0644->0755]
src/cacaoh/dummy.c
src/mm/boehm-gc/autogen.sh [changed mode: 0644->0755]
src/native/vm/gnu/java_lang_reflect_Constructor.c
src/native/vm/gnu/java_lang_reflect_Field.c
src/native/vm/gnu/java_lang_reflect_Method.c
src/native/vm/gnu/sun_reflect_ConstantPool.c
src/native/vm/java_lang_Class.c
src/vmcore/annotation.c
src/vmcore/annotation.h
src/vmcore/class.c
src/vmcore/class.h
src/vmcore/field.c
src/vmcore/loader.c
src/vmcore/method.c
src/vmcore/utf8.c
src/vmcore/utf8.h

old mode 100644 (file)
new mode 100755 (executable)
index 62fdb5472c64290e043d490c4aa1aa7e7f9603e9..10420a3c995dea6ed3e93d0563fe2e9deedcee10 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
@@ -75,6 +79,60 @@ bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
 }
 
 
+/* array **********************************************************************/
+
+java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index)
+{
+       java_handle_t *value;
+       int32_t        size;
+
+       if (a == NULL) {
+               log_println("array_objectarray_element_get(a=%p, index=%d): NullPointerException", a, index);
+               return NULL;
+       }
+
+       size = LLNI_array_size(a);
+
+       if ((index < 0) || (index > size)) {
+               log_println("array_objectarray_element_get(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
+               return NULL;
+       }
+
+       value = LLNI_array_direct(a, index);
+
+       return value;
+}
+
+void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
+{
+       int32_t size;
+
+       if (a == NULL) {
+               log_println("array_objectarray_element_set(a=%p, index=%d): NullPointerException", a, index);
+               return;
+       }
+
+       size = LLNI_array_size(a);
+
+       if ((index < 0) || (index > size)) {
+               log_println("array_objectarray_element_set(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
+               return;
+       }
+
+       LLNI_array_direct(a, index) = value;
+}
+
+int32_t array_length_get(java_handle_t *a)
+{
+       if (a == NULL) {
+               log_println("array_length_get(a=%p): NullPointerException", a);
+               return 0;
+       }
+
+       return LLNI_array_size(a);
+}
+
+
 /* asm ************************************************************************/
 
 void asm_abstractmethoderror(void)
@@ -123,16 +181,26 @@ java_handle_t *builtin_new(classinfo *c)
 
 java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
 {
-       abort();
+       java_handle_objectarray_t *oa = (java_handle_objectarray_t*)mem_alloc(
+               sizeof(java_array_t) + size * sizeof(java_object_t*));
 
-       return NULL;
+       if (oa != NULL) {
+               LLNI_array_size(oa) = size;
+       }
+
+       return oa;
 }
 
 java_handle_bytearray_t *builtin_newarray_byte(int32_t size)
 {
-       abort();
+       java_handle_bytearray_t *ba = (java_handle_bytearray_t*)mem_alloc(
+               sizeof(java_array_t) + size * sizeof(int8_t));
 
-       return NULL;
+       if (ba != NULL) {
+               LLNI_array_size(ba) = size;
+       }
+       
+       return ba;
 }
 
 
@@ -464,6 +532,11 @@ int32_t dump_size(void)
 
 /* primitive ******************************************************************/
 
+classinfo *primitive_arrayclass_get_by_type(int type)
+{
+       return NULL;
+}
+
 classinfo *primitive_class_get_by_type(int type)
 {
        abort();
old mode 100644 (file)
new mode 100755 (executable)
index c12b9eb213acb5d245a087196e57e74922c4fbb9..eac5d6a02bca862594a860dc112eacf0112a5725 100644 (file)
@@ -112,7 +112,6 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_construct
  */
 JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this)
 {
-       java_handle_t           *o                   = (java_handle_t*)this;
        struct java_util_Map    *declaredAnnotations = NULL;
        java_handle_bytearray_t *annotations         = NULL;
        java_lang_Class         *declaringClass      = NULL;
@@ -141,7 +140,6 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_decla
  */
 JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this)
 {
-       java_handle_t           *o                    = (java_handle_t*)this;
        java_handle_bytearray_t *parameterAnnotations = NULL;
        int32_t                  slot                 = -1;
        java_lang_Class         *declaringClass       = NULL;
index 261fbfb03ff737c8b6424946c2bad3ebb82fe9ee..8da63369147cc02efa5ad231e5d6a7d2edd8b5bc 100644 (file)
@@ -1251,7 +1251,6 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JN
  */
 JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Field_declaredAnnotations(JNIEnv *env, java_lang_reflect_Field *this)
 {
-       java_handle_t           *o                   = (java_handle_t*)this;
        struct java_util_Map    *declaredAnnotations = NULL;
        java_handle_bytearray_t *annotations         = NULL;
        java_lang_Class         *declaringClass      = NULL;
index 150e46201c91d15310c4d2b8fb6b1467a3098491..32d84d545d775e6bdeac5d5fef3061d4c939cc3a 100644 (file)
@@ -229,7 +229,6 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefa
        utf                      *utf_parseAnnotationDefault = NULL;
        utf                      *utf_desc        = NULL;
        sun_reflect_ConstantPool *constantPool    = NULL;
-       java_handle_t            *o               = (java_handle_t*)this;
        java_lang_Class          *constantPoolOop = NULL;
        classinfo                *referer         = NULL;
 
@@ -290,7 +289,6 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefa
  */
 JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAnnotations(JNIEnv *env, java_lang_reflect_Method *this)
 {
-       java_handle_t           *o                   = (java_handle_t*)this;
        struct java_util_Map    *declaredAnnotations = NULL;
        java_handle_bytearray_t *annotations         = NULL;
        java_lang_Class         *declaringClass      = NULL;
@@ -319,7 +317,6 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAn
  */
 JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Method_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Method *this)
 {
-       java_handle_t           *o                    = (java_handle_t*)this;
        java_handle_bytearray_t *parameterAnnotations = NULL;
        int32_t                  slot                 = -1;
        java_lang_Class         *declaringClass       = NULL;
index 98b739897501133652bdd70cd69b0f0019971274..cf6bc2aa4e1b69bc5a9dd8ab440c7562f10ebfaa 100644 (file)
@@ -87,7 +87,7 @@ static JNINativeMethod methods[] = {
 
 void _Jv_sun_reflect_ConstantPool_init(void)
 {
-       native_method_register(utf_sun_reflect_ConstantPool, methods, NATIVE_METHODS_COUNT);
+       native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT);
 }
 
 /*
index 12b534177051ddd93da0014e99250609ab47a48b..2240817e5637120fd53428a6870b4185d7a8e64d 100644 (file)
 #include "vmcore/loader.h"
 
 #if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
+#include "native/include/sun_reflect_ConstantPool.h"
+
 #include "vm/vm.h"
+
 #include "vmcore/annotation.h"
-#include "native/include/sun_reflect_ConstantPool.h"
 #endif
 
 /*
@@ -637,7 +639,7 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_
 
        if (exceptions_get_exception() != NULL) {
                /* the only exception possible here should be a out of memory exception
-                * raised by copying the annotations into a java bytearray */
+                * raised by copying the annotations into a new java bytearray */
                return NULL;
        }
 
index 81ec65ede6bd9eaadbef0ab814cd7b022ded911d..1807653fa8ada71b2d8865a73b51631318f87782 100644 (file)
 
 #include <assert.h>
 
+#include "native/llni.h"
+
 #include "vm/types.h"
+#include "vm/array.h"
+#include "vm/builtin.h"
+#include "vm/primitive.h"
 
 #include "mm/memory.h"
 
 # error annotation support has to be enabled when compling this file!
 #endif
 
-/* annotation_bytearray_new ***************************************************
-
-   Allocate a new bytearray.
-
-*******************************************************************************/
-
-annotation_bytearray_t *annotation_bytearray_new(uint32_t size)
-{
-       annotation_bytearray_t *ba =
-               mem_alloc(sizeof(uint32_t) + sizeof(uint8_t) * size);
-
-       if (ba != NULL) {
-               ba->size = size;
-       }
-
-       return ba;
-}
-
-
-/* annotation_bytearray_free **************************************************
-
-   Free a bytearray.
-
-*******************************************************************************/
-
-void annotation_bytearray_free(annotation_bytearray_t *ba)
-{
-       if (ba != NULL) {
-               mem_free(ba, sizeof(uint32_t) + sizeof(uint8_t) * ba->size);
-       }
-}
-
-
-/* annotation_bytearrays_new **************************************************
-
-   Allocate a new array of bytearrays.
-
-*******************************************************************************/
-
-annotation_bytearrays_t *annotation_bytearrays_new(uint32_t size)
-{
-       annotation_bytearrays_t *bas =
-               mem_alloc(sizeof(uint32_t) + sizeof(annotation_bytearray_t*) * size);
-
-       if (bas != NULL) {
-               bas->size = size;
-       }
-
-       return bas;
-}
-
 
 /* annotation_bytearrays_resize ***********************************************
 
@@ -100,31 +54,39 @@ annotation_bytearrays_t *annotation_bytearrays_new(uint32_t size)
 
 *******************************************************************************/
 
-bool annotation_bytearrays_resize(annotation_bytearrays_t **bas,
+static bool annotation_bytearrays_resize(java_handle_objectarray_t **bas,
        uint32_t size)
 {
-       annotation_bytearrays_t *newbas = NULL;
+       java_handle_objectarray_t *newbas = NULL;
+       java_handle_t             *o;
        uint32_t i;
        uint32_t minsize;
+       uint32_t oldsize;
        
        assert(bas != NULL);
        
-       newbas = annotation_bytearrays_new(size);
+       /* if the size already fits do nothing */
+       if (*bas != NULL) {
+               oldsize = array_length_get((java_handle_t*)*bas);
+
+               if (size == oldsize) {
+                       return true;
+               }
+       }
+
+       newbas = builtin_anewarray(size,
+               primitive_arrayclass_get_by_type(PRIMITIVETYPE_BYTE));
        
        if (newbas == NULL) {
+               /* out of memory */
                return false;
        }
        
+       /* is there a old byte array array? */
        if (*bas != NULL) {
-               minsize = size < (*bas)->size ? size : (*bas)->size;
-
-               for (i = size; i < (*bas)->size; ++ i) {
-                       annotation_bytearray_free((*bas)->data[i]);
-               }
+               minsize = size < oldsize ? size : oldsize;
 
-               for (i = 0; i < minsize; ++i) {
-                       newbas->data[i] = (*bas)->data[i];
-               }
+               MCOPY(LLNI_array_data(newbas), LLNI_array_data(*bas), java_object_t*, minsize);
        }
 
        *bas = newbas;
@@ -139,56 +101,45 @@ bool annotation_bytearrays_resize(annotation_bytearrays_t **bas,
 
 *******************************************************************************/
 
-bool annotation_bytearrays_insert(annotation_bytearrays_t **bas,
-       uint32_t index, annotation_bytearray_t *ba)
+static bool annotation_bytearrays_insert(java_handle_objectarray_t **bas,
+       uint32_t index, java_handle_bytearray_t *ba)
 {
+       uint32_t size = 0;
+
        assert(bas != NULL);
 
-       if (ba != NULL) {
-               if (*bas == NULL || (*bas)->size <= index) {
+       /* do nothing if NULL is inserted but no array exists */
+       if (ba == NULL && *bas == NULL) {
+               return true;
+       }
+
+       /* get lengths if array exists */
+       if (*bas != NULL) {
+               size = array_length_get((java_handle_t*)*bas);
+       }
+
+       if (ba == NULL) {
+               /* insert NULL only if array is big enough */
+               if (size > index) {
+                       array_objectarray_element_set(*bas, index, NULL);
+               }
+       }
+       else {
+               /* resize array if it's not enough for inserted value */
+               if (size <= index) {
                        if (!annotation_bytearrays_resize(bas, index + 1)) {
+                               /* out of memory */
                                return false;
                        }
                }
-               else {
-                       /* free old bytearray (if any) */
-                       annotation_bytearray_free((*bas)->data[index]);
-               }
 
-               /* insert new bytearray */
-               (*bas)->data[index] = ba;
+               array_objectarray_element_set(*bas, index, (java_handle_t*)ba);
        }
-       else if (*bas != NULL && (*bas)->size > index) {
-               /* do not resize when just inserting NULL,
-                * but free old bytearray if there is any */
-               annotation_bytearray_free((*bas)->data[index]);
-       }
-
+       
        return true;
 }
 
 
-/* annotation_bytearrays_free *************************************************
-
-   Free an array of bytearrays.
-
-*******************************************************************************/
-
-void annotation_bytearrays_free(annotation_bytearrays_t *bas)
-{
-       uint32_t i;
-
-       if (bas != NULL) {
-               for (i = 0; i < bas->size; ++ i) {
-                       annotation_bytearray_free(bas->data[i]);
-               }
-
-               mem_free(bas, sizeof(uint32_t) +
-                       sizeof(annotation_bytearray_t*) * bas->size);
-       }
-}
-
-
 /* annotation_load_attribute_body *********************************************
 
    This function loads the body of a generic attribute.
@@ -215,10 +166,10 @@ void annotation_bytearrays_free(annotation_bytearrays_t *bas)
 *******************************************************************************/
 
 static bool annotation_load_attribute_body(classbuffer *cb,
-       annotation_bytearray_t **attribute, const char *errormsg_prefix)
+       java_handle_bytearray_t **attribute, const char *errormsg_prefix)
 {
        uint32_t size = 0;
-       annotation_bytearray_t *ba = NULL;
+       java_handle_bytearray_t *ba = NULL;
 
        assert(cb != NULL);
        assert(attribute != NULL);
@@ -239,7 +190,7 @@ static bool annotation_load_attribute_body(classbuffer *cb,
        /* if attribute_length == 0 then NULL is
         * the right value for this attribute */
        if (size > 0) {
-               ba = annotation_bytearray_new(size);
+               ba = builtin_newarray_byte(size);
 
                if (ba == NULL) {
                        /* out of memory */
@@ -247,7 +198,7 @@ static bool annotation_load_attribute_body(classbuffer *cb,
                }
 
                /* load data */
-               suck_nbytes(ba->data, cb, size);
+               suck_nbytes((uint8_t*)LLNI_array_data(ba), cb, size);
 
                /* return data */
                *attribute = ba;
@@ -282,8 +233,8 @@ bool annotation_load_method_attribute_annotationdefault(
                classbuffer *cb, methodinfo *m)
 {
        int slot = 0;
-       annotation_bytearray_t   *annotationdefault  = NULL;
-       annotation_bytearrays_t **annotationdefaults = NULL;
+       java_handle_bytearray_t    *annotationdefault  = NULL;
+       java_handle_objectarray_t **annotationdefaults = NULL;
 
        assert(cb != NULL);
        assert(m != NULL);
@@ -291,8 +242,8 @@ bool annotation_load_method_attribute_annotationdefault(
        annotationdefaults = &(m->class->method_annotationdefaults);
 
        if (!annotation_load_attribute_body(
-               cb, &annotationdefault,
-               "invalid annotation default method attribute")) {
+                       cb, &annotationdefault,
+                       "invalid annotation default method attribute")) {
                return false;
        }
 
@@ -300,8 +251,7 @@ bool annotation_load_method_attribute_annotationdefault(
                slot = m - m->class->methods;
 
                if (!annotation_bytearrays_insert(
-                       annotationdefaults, slot, annotationdefault)) {
-                       annotation_bytearray_free(annotationdefault);
+                               annotationdefaults, slot, annotationdefault)) {
                        return false;
                }
        }
@@ -339,8 +289,8 @@ bool annotation_load_method_attribute_runtimevisibleparameterannotations(
                classbuffer *cb, methodinfo *m)
 {
        int slot = 0;
-       annotation_bytearray_t  *annotations = NULL;
-       annotation_bytearrays_t **parameterannotations = NULL;
+       java_handle_bytearray_t    *annotations          = NULL;
+       java_handle_objectarray_t **parameterannotations = NULL;
 
        assert(cb != NULL);
        assert(m != NULL);
@@ -348,8 +298,8 @@ bool annotation_load_method_attribute_runtimevisibleparameterannotations(
        parameterannotations = &(m->class->method_parameterannotations);
 
        if (!annotation_load_attribute_body(
-               cb, &annotations,
-               "invalid runtime visible parameter annotations method attribute")) {
+                       cb, &annotations,
+                       "invalid runtime visible parameter annotations method attribute")) {
                return false;
        }
 
@@ -357,8 +307,7 @@ bool annotation_load_method_attribute_runtimevisibleparameterannotations(
                slot = m - m->class->methods;
 
                if (!annotation_bytearrays_insert(
-                       parameterannotations, slot, annotations)) {
-                       annotation_bytearray_free(annotations);
+                               parameterannotations, slot, annotations)) {
                        return false;
                }
        }
@@ -455,8 +404,8 @@ bool annotation_load_method_attribute_runtimevisibleannotations(
        classbuffer *cb, methodinfo *m)
 {
        int slot = 0;
-       annotation_bytearray_t  *annotations = NULL;
-       annotation_bytearrays_t **method_annotations = NULL;
+       java_handle_bytearray_t    *annotations        = NULL;
+       java_handle_objectarray_t **method_annotations = NULL;
 
        assert(cb != NULL);
        assert(m != NULL);
@@ -464,8 +413,8 @@ bool annotation_load_method_attribute_runtimevisibleannotations(
        method_annotations = &(m->class->method_annotations);
 
        if (!annotation_load_attribute_body(
-               cb, &annotations,
-               "invalid runtime visible annotations method attribute")) {
+                       cb, &annotations,
+                       "invalid runtime visible annotations method attribute")) {
                return false;
        }
 
@@ -473,8 +422,7 @@ bool annotation_load_method_attribute_runtimevisibleannotations(
                slot = m - m->class->methods;
 
                if (!annotation_bytearrays_insert(
-                       method_annotations, slot, annotations)) {
-                       annotation_bytearray_free(annotations);
+                               method_annotations, slot, annotations)) {
                        return false;
                }
        }
@@ -506,8 +454,8 @@ bool annotation_load_field_attribute_runtimevisibleannotations(
        classbuffer *cb, fieldinfo *f)
 {
        int slot = 0;
-       annotation_bytearray_t  *annotations = NULL;
-       annotation_bytearrays_t **field_annotations = NULL;
+       java_handle_bytearray_t    *annotations       = NULL;
+       java_handle_objectarray_t **field_annotations = NULL;
 
        assert(cb != NULL);
        assert(f != NULL);
@@ -515,8 +463,8 @@ bool annotation_load_field_attribute_runtimevisibleannotations(
        field_annotations = &(f->class->field_annotations);
 
        if (!annotation_load_attribute_body(
-               cb, &annotations,
-               "invalid runtime visible annotations field attribute")) {
+                       cb, &annotations,
+                       "invalid runtime visible annotations field attribute")) {
                return false;
        }
 
@@ -524,8 +472,7 @@ bool annotation_load_field_attribute_runtimevisibleannotations(
                slot = f - f->class->fields;
 
                if (!annotation_bytearrays_insert(
-                       field_annotations, slot, annotations)) {
-                       annotation_bytearray_free(annotations);
+                               field_annotations, slot, annotations)) {
                        return false;
                }
        }
index c224ebe8494fd97782b7f4da4f85b76eeea95f37..b33a78fd99d1ec8987f0fd9464bcd8cb85e50f32 100644 (file)
 #ifndef _ANNOTATION_H
 #define _ANNOTATION_H
 
-/* forward typedefs ***********************************************************/
-
-typedef struct annotation_bytearray_t annotation_bytearray_t;
-typedef struct annotation_t           annotation_t;
-typedef struct element_value_t        element_value_t;
-typedef struct annotation_bytearrays_t annotation_bytearrays_t;
 
 #include "config.h"
 #include "vm/types.h"
@@ -47,38 +41,8 @@ typedef struct annotation_bytearrays_t annotation_bytearrays_t;
 #include "vmcore/utf8.h"
 
 
-/* annotation_bytearray *******************************************************/
-
-struct annotation_bytearray_t {
-       uint32_t size;
-       uint8_t  data[1];
-};
-
-
-/* annotation_bytearrays ******************************************************/
-
-struct annotation_bytearrays_t {
-       uint32_t size;
-       annotation_bytearray_t *data[1];
-};
-
-
 /* function prototypes ********************************************************/
 
-annotation_bytearray_t *annotation_bytearray_new(uint32_t size);
-
-void annotation_bytearray_free(annotation_bytearray_t *ba);
-
-annotation_bytearrays_t *annotation_bytearrays_new(uint32_t size);
-
-bool annotation_bytearrays_resize(annotation_bytearrays_t **bas,
-       uint32_t size);
-
-bool annotation_bytearrays_insert(annotation_bytearrays_t **bas,
-       uint32_t index, annotation_bytearray_t *ba);
-
-void annotation_bytearrays_free(annotation_bytearrays_t *bas);
-
 bool annotation_load_class_attribute_runtimevisibleannotations(
        classbuffer *cb);
 
index 3b2b0a377de732b4b2825bbc374ad81bef54b511..51ddc07bb38667c4ebf0ac5e40cc0a8110baea98 100644 (file)
@@ -138,9 +138,11 @@ classinfo *arrayclass_java_lang_Object;
 
 #if defined(ENABLE_ANNOTATIONS)
 classinfo *class_sun_reflect_ConstantPool;
+#if defined(WITH_CLASSPATH_GNU)
 classinfo *class_sun_reflect_annotation_AnnotationParser;
 #endif
 #endif
+#endif
 
 
 /* pseudo classes for the typechecker */
@@ -841,16 +843,6 @@ void class_free(classinfo *c)
                mem_free(c->header.vftbl, sizeof(vftbl) + sizeof(methodptr)*(c->vftbl->vftbllength-1)); */
        
 /*     GCFREE(c); */
-
-#if defined(ENABLE_ANNOTATIONS)
-       annotation_bytearray_free(c->annotations);
-
-       annotation_bytearrays_free(c->method_annotations);
-       annotation_bytearrays_free(c->method_parameterannotations);
-       annotation_bytearrays_free(c->method_annotationdefaults);
-
-       annotation_bytearrays_free(c->field_annotations);
-#endif
 }
 
 
@@ -1995,25 +1987,7 @@ java_handle_objectarray_t *class_get_interfaces(classinfo *c)
 java_handle_bytearray_t *class_get_annotations(classinfo *c)
 {
 #if defined(ENABLE_ANNOTATIONS)
-       java_handle_bytearray_t  *annotations = NULL;
-       uint32_t                  size        = 0;
-       
-       /* Return null for arrays and primitives: */
-       if (class_is_primitive(c) || class_is_array(c)) {
-               return NULL;
-       }
-
-       /* copy the annotations into a java byte array: */
-       if (c->annotations != NULL) {
-               size        = c->annotations->size;
-               annotations = builtin_newarray_byte(size);
-
-               if(annotations != NULL) {
-                       MCOPY(annotations->data, c->annotations->data, uint8_t, size);
-               }
-       }
-
-       return annotations;
+       return c->annotations;
 #else
        return NULL;
 #endif
index 48ade646e805c60ce6febae28e23f11c0ed28145..fddb1279da5cf5b6b9e24b778f23a44402d45119 100644 (file)
@@ -145,19 +145,19 @@ struct classinfo {                /* class structure                          */
 #if defined(ENABLE_JAVASE)
        utf        *signature;        /* Signature attribute                      */
 #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        */
+       /* All the annotation attributes are NULL (and not a zero length array)   */
+       /* if there is nothing.                                                   */
+       java_handle_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         */
+       java_handle_objectarray_t *method_annotations; /* array of annotations    */
+                                     /* for the methods                          */
+       java_handle_objectarray_t *method_parameterannotations; /* array of       */
                                      /* parameter annotations for the methods    */
-       annotation_bytearrays_t *method_annotationdefaults; /* array for          */
+       java_handle_objectarray_t *method_annotationdefaults; /* array for        */
                                      /* annotation default values for the        */
-                                     /* methods                                  */
+                                     /* methods                                  */
 
-       annotation_bytearrays_t *field_annotations; /* array of annotations for   */
+       java_handle_objectarray_t *field_annotations; /* array of annotations for */
                                      /* the fields                               */
 #endif
 #endif
index ef66b82bf77760709b0d23f634946155d29a07cc..f3b97712fb4ffd6d1282acf58d30a5940e3c065c 100644 (file)
@@ -395,23 +395,17 @@ java_handle_bytearray_t *field_get_annotations(fieldinfo *f)
 #if defined(ENABLE_ANNOTATIONS)
        classinfo               *c;
        int                      slot;
-       annotation_bytearray_t  *ba;
        java_handle_bytearray_t *annotations;
 
        c           = f->class;
        slot        = f - c->fields;
        annotations = NULL;
        
-       if (c->field_annotations != NULL && c->field_annotations->size > slot) {
-               ba = c->field_annotations->data[slot];
-               
-               if (ba != NULL) {
-                       annotations = builtin_newarray_byte(ba->size);
-                       
-                       if (annotations != NULL) {
-                               MCOPY(annotations->data, ba->data, uint8_t, ba->size);
-                       }
-               }
+       if (c->field_annotations != NULL &&
+           array_length_get(c->field_annotations) > slot) {
+               annotations = (java_handle_bytearray_t*)
+                       array_objectarray_element_get(
+                               c->field_annotations, slot);
        }
        
        return annotations;
index cd65977f3aa94a57e39564e7a869afccb15459d3..060d0e2b3ec16f3971cae15dfb1e0628534a9a08 100644 (file)
@@ -230,13 +230,13 @@ bool loader_init(void)
 #if defined(ENABLE_ANNOTATIONS)
        /* needed by annotation support */
        if (!(class_sun_reflect_ConstantPool = 
-                 load_class_bootstrap(utf_sun_reflect_ConstantPool)))
+                 load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool"))))
                return false;
 
 #if defined(WITH_CLASSPATH_GNU)
        /* needed by GNU Classpaths annotation support */
        if (!(class_sun_reflect_annotation_AnnotationParser = 
-                 load_class_bootstrap(utf_sun_reflect_annotation_AnnotationParser)))
+                 load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser"))))
                return false;
 #endif
 #endif
index 17e40bd785443145b26172755bdd0cd3b1290fc0..949bce288cca72c8e796a0e5f0e13bf21f55d18e 100644 (file)
@@ -785,23 +785,15 @@ java_handle_bytearray_t *method_get_annotations(methodinfo *m)
 #if defined(ENABLE_ANNOTATIONS)
        classinfo               *c;
        int                      slot;
-       annotation_bytearray_t  *ba;
        java_handle_bytearray_t *annotations;
 
        c           = m->class;
        slot        = m - c->methods;
        annotations = NULL;
        
-       if (c->method_annotations != NULL && c->method_annotations->size > slot) {
-               ba = c->method_annotations->data[slot];
-               
-               if (ba != NULL) {
-                       annotations = builtin_newarray_byte(ba->size);
-                       
-                       if (annotations != NULL) {
-                               MCOPY(annotations->data, ba->data, uint8_t, ba->size);
-                       }
-               }
+       if (c->method_annotations != NULL && array_length_get(c->method_annotations) > slot) {
+               annotations = (java_handle_bytearray_t*)array_objectarray_element_get(
+                       c->method_annotations, slot);
        }
        
        return annotations;
@@ -822,7 +814,6 @@ java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
 #if defined(ENABLE_ANNOTATIONS)
        classinfo               *c;
        int                      slot;
-       annotation_bytearray_t  *ba;
        java_handle_bytearray_t *parameterAnnotations;
 
        c                    = m->class;
@@ -830,16 +821,10 @@ java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
        parameterAnnotations = NULL;
 
        if (c->method_parameterannotations != NULL &&
-               c->method_parameterannotations->size > slot) {
-               ba = c->method_parameterannotations->data[slot];
-               
-               if (ba != NULL) {
-                       parameterAnnotations = builtin_newarray_byte(ba->size);
-                       
-                       if (parameterAnnotations != NULL) {
-                               MCOPY(parameterAnnotations->data, ba->data, uint8_t, ba->size);
-                       }
-               }
+                       array_length_get(c->method_parameterannotations) > slot) {
+               parameterAnnotations =
+                       (java_handle_bytearray_t*)array_objectarray_element_get(
+                               c->method_parameterannotations, slot);
        }
        
        return parameterAnnotations;
@@ -860,7 +845,6 @@ java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
 #if defined(ENABLE_ANNOTATIONS)
        classinfo               *c;
        int                      slot;
-       annotation_bytearray_t  *ba;
        java_handle_bytearray_t *annotationDefault;
 
        c                 = m->class;
@@ -868,16 +852,10 @@ java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
        annotationDefault = NULL;
 
        if (c->method_annotationdefaults != NULL &&
-               c->method_annotationdefaults->size > slot) {
-               ba = c->method_annotationdefaults->data[slot];
-               
-               if (ba != NULL) {
-                       annotationDefault = builtin_newarray_byte(ba->size);
-                       
-                       if (annotationDefault != NULL) {
-                               MCOPY(annotationDefault->data, ba->data, uint8_t, ba->size);
-                       }
-               }
+                       array_length_get(c->method_annotationdefaults) > slot) {
+               annotationDefault = 
+                       (java_handle_bytearray_t*)array_objectarray_element_get(
+                               c->method_annotationdefaults, slot);
        }
        
        return annotationDefault;
index ce7641c1a4576d924d64209bc948942001302a51..297cfe494014a22b2fb18f2d78e2b436541e3786 100644 (file)
@@ -153,11 +153,6 @@ utf *utf_Signature;
 utf *utf_StackMapTable;
 
 #if defined(ENABLE_ANNOTATIONS)
-utf *utf_sun_reflect_ConstantPool;
-#if defined(WITH_CLASSPATH_GNU)
-utf *utf_sun_reflect_annotation_AnnotationParser;
-#endif
-
 utf *utf_RuntimeVisibleAnnotations;
 utf *utf_RuntimeInvisibleAnnotations;
 utf *utf_RuntimeVisibleParameterAnnotations;
@@ -408,11 +403,6 @@ bool utf8_init(void)
        utf_StackMapTable              = utf_new_char("StackMapTable");
 
 #if defined(ENABLE_ANNOTATIONS)
-       utf_sun_reflect_ConstantPool                = utf_new_char("sun/reflect/ConstantPool");
-#if defined(WITH_CLASSPATH_GNU)
-       utf_sun_reflect_annotation_AnnotationParser = utf_new_char("sun/reflect/annotation/AnnotationParser");
-#endif
-
        utf_RuntimeVisibleAnnotations            = utf_new_char("RuntimeVisibleAnnotations");
        utf_RuntimeInvisibleAnnotations          = utf_new_char("RuntimeInvisibleAnnotations");
        utf_RuntimeVisibleParameterAnnotations   = utf_new_char("RuntimeVisibleParameterAnnotations");
index fff7d340a791dbbb396cd5d7bb3aa74142be4aa5..441cf4507f9e84c33acbeed86014ce0a84a48eea 100644 (file)
@@ -149,16 +149,6 @@ extern utf *utf_Signature;
 extern utf *utf_StackMapTable;
 
 #if defined(ENABLE_ANNOTATIONS)
-/* OpenJDKs sun.reflect.ConstantPool class is for now only
- * used by annotations but will probably be used for other
- * things in the future. For now I just couple it with
- * annotation support.
- */
-extern utf *utf_sun_reflect_ConstantPool;
-#if defined(WITH_CLASSPATH_GNU)
-extern utf *utf_sun_reflect_annotation_AnnotationParser;
-#endif
-
 extern utf *utf_RuntimeVisibleAnnotations;
 extern utf *utf_RuntimeInvisibleAnnotations;
 extern utf *utf_RuntimeVisibleParameterAnnotations;