Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: reflect.c 8305 2007-08-15 13:49:26Z panzi $
-
*/
#include "native/include/java_lang_reflect_Field.h"
#include "native/include/java_lang_reflect_Method.h"
-#include "native/vm/java_lang_String.h"
#include "native/vm/reflect.h"
#include "vm/builtin.h"
java_handle_t *o;
java_lang_reflect_Constructor *rc;
int32_t slot;
- java_bytearray *annotations = NULL;
- java_bytearray *parameterAnnotations = NULL;
- annotation_bytearray_t *ba = NULL;
-
-#if defined(ENABLE_ANNOTATIONS)
- /* get annotations */
- ba = method_get_annotations(m);
-
- if (ba != NULL) {
- annotations = builtin_newarray_byte(ba->size);
-
- if (annotations == NULL)
- return NULL;
-
- MCOPY(annotations->data, ba->data, uint8_t, ba->size);
- }
-
- /* get parameter annotations */
- ba = method_get_parameterannotations(m);
-
- if (ba != NULL) {
- parameterAnnotations = builtin_newarray_byte(ba->size);
-
- if (parameterAnnotations == NULL)
- return NULL;
-
- MCOPY(parameterAnnotations->data, ba->data, uint8_t, ba->size);
- }
-#endif
/* get declaring class */
- c = (classinfo *) m->class;
+ c = m->class;
/* allocate a new object */
LLNI_field_set_cls(rc, clazz , c);
LLNI_field_set_val(rc, slot , slot);
- LLNI_field_set_ref(rc, annotations , annotations);
- LLNI_field_set_ref(rc, parameterAnnotations, parameterAnnotations);
+ LLNI_field_set_ref(rc, annotations , method_get_annotations(m));
+ LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
#elif defined(WITH_CLASSPATH_SUN)
LLNI_field_set_val(rc, modifiers , m->flags & ACC_CLASS_REFLECT_MASK);
LLNI_field_set_val(rc, slot , slot);
LLNI_field_set_ref(rc, signature , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
- LLNI_field_set_ref(rc, annotations , annotations);
- LLNI_field_set_ref(rc, parameterAnnotations, parameterAnnotations);
+ LLNI_field_set_ref(rc, annotations , method_get_annotations(m));
+ LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
#else
# error unknown classpath configuration
java_handle_t *o;
java_lang_reflect_Field *rf;
int32_t slot;
- java_bytearray *annotations = NULL;
- annotation_bytearray_t *ba = NULL;
-
-#if defined(ENABLE_ANNOTATIONS)
- /* get annotations */
- ba = field_get_annotations(f);
-
- if (ba != NULL) {
- annotations = builtin_newarray_byte(ba->size);
-
- if (annotations == NULL)
- return NULL;
-
- MCOPY(annotations->data, ba->data, uint8_t, ba->size);
- }
-#endif
/* get declaring class */
- c = (classinfo *) f->class;
+ c = f->class;
/* allocate a new object */
/* The name needs to be interned */
/* XXX implement me better! */
- LLNI_field_set_ref(rf, name , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(f->name)));
+ LLNI_field_set_ref(rf, name , javastring_intern((java_lang_String *) javastring_new(f->name)));
LLNI_field_set_val(rf, slot , slot);
- LLNI_field_set_ref(rf, annotations , annotations);
+ LLNI_field_set_ref(rf, annotations , field_get_annotations(f));
#elif defined(WITH_CLASSPATH_SUN)
/* The name needs to be interned */
/* XXX implement me better! */
- LLNI_field_set_ref(rf, name , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(f->name)));
+ LLNI_field_set_ref(rf, name , javastring_intern((java_lang_String *) javastring_new(f->name)));
LLNI_field_set_cls(rf, type , (java_lang_Class *) field_get_type(f));
LLNI_field_set_val(rf, modifiers , f->flags);
LLNI_field_set_val(rf, slot , slot);
LLNI_field_set_ref(rf, signature , f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL);
- LLNI_field_set_ref(rf, annotations , annotations);
+ LLNI_field_set_ref(rf, annotations , field_get_annotations(f));
#else
# error unknown classpath configuration
java_handle_t *o;
java_lang_reflect_Method *rm;
int32_t slot;
- java_bytearray *annotations = NULL;
- java_bytearray *parameterAnnotations = NULL;
- java_bytearray *annotationDefault = NULL;
- annotation_bytearray_t *ba = NULL;
-
-#if defined(ENABLE_ANNOTATIONS)
- /* get annotations */
- ba = method_get_annotations(m);
-
- if (ba != NULL) {
- annotations = builtin_newarray_byte(ba->size);
-
- if (annotations == NULL)
- return NULL;
-
- MCOPY(annotations->data, ba->data, uint8_t, ba->size);
- }
-
- /* get parameter annotations */
- ba = method_get_parameterannotations(m);
-
- if (ba != NULL) {
- parameterAnnotations = builtin_newarray_byte(ba->size);
-
- if (parameterAnnotations == NULL)
- return NULL;
-
- MCOPY(parameterAnnotations->data, ba->data, uint8_t, ba->size);
- }
-
- /* get annotation default value */
- ba = method_get_annotationdefault(m);
-
- if (ba != NULL) {
- annotationDefault = builtin_newarray_byte(ba->size);
-
- if (annotationDefault == NULL)
- return NULL;
-
- MCOPY(annotationDefault->data, ba->data, uint8_t, ba->size);
- }
-#endif
/* get declaring class */
- c = (classinfo *) m->class;
+ c = m->class;
/* allocate a new object */
/* The name needs to be interned */
/* XXX implement me better! */
- LLNI_field_set_ref(rm, name , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name)));
+ LLNI_field_set_ref(rm, name , javastring_intern((java_lang_String *) javastring_new(m->name)));
LLNI_field_set_val(rm, slot , slot);
- LLNI_field_set_ref(rm, annotations , annotations);
- LLNI_field_set_ref(rm, parameterAnnotations, parameterAnnotations);
- LLNI_field_set_ref(rm, annotationDefault , annotationDefault);
+ LLNI_field_set_ref(rm, annotations , method_get_annotations(m));
+ LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
+ LLNI_field_set_ref(rm, annotationDefault , method_get_annotationdefault(m));
#elif defined(WITH_CLASSPATH_SUN)
- LLNI_field_set_cls(rm, clazz , (java_lang_Class *) m->class);
+ LLNI_field_set_cls(rm, clazz , m->class);
/* The name needs to be interned */
/* XXX implement me better! */
- rm->name = _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name));
- rm->parameterTypes = method_get_parametertypearray(m);
- rm->returnType = (java_lang_Class *) method_returntype_get(m);
- rm->exceptionTypes = method_get_exceptionarray(m);
- rm->modifiers = m->flags & ACC_CLASS_REFLECT_MASK;
- rm->slot = slot;
- rm->signature = m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL;
- rm->annotations = annotations;
- rm->parameterAnnotations = parameterAnnotations;
- rm->annotationDefault = annotationDefault;
+ LLNI_field_set_ref(rm, name , javastring_intern((java_lang_String *) javastring_new(m->name)));
+ LLNI_field_set_ref(rm, parameterTypes , method_get_parametertypearray(m));
+ LLNI_field_set_cls(rm, returnType , (java_lang_Class *) method_returntype_get(m));
+ LLNI_field_set_ref(rm, exceptionTypes , method_get_exceptionarray(m));
+ LLNI_field_set_val(rm, modifiers , m->flags & ACC_CLASS_REFLECT_MASK);
+ LLNI_field_set_val(rm, slot , slot);
+ LLNI_field_set_ref(rm, signature , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
+ LLNI_field_set_ref(rm, annotations , method_get_annotations(m));
+ LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
+ LLNI_field_set_ref(rm, annotationDefault , method_get_annotationdefault(m));
#else
# error unknown classpath configuration
#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
/* reflect_get_declaredannotatios *********************************************
- Returns a java.util.Map<Class, Annotation> of the declared
- annotations.
+ Returns a java.util.Map<Class<? extends Annotation>, Annotation>
+ of the declared annotations.
*******************************************************************************/
struct java_util_Map* reflect_get_declaredannotatios(
- java_bytearray *annotations,
- java_lang_Class *declaringClass,
- classinfo *referer)
+ java_handle_bytearray_t *annotations,
+ java_lang_Class *declaringClass,
+ classinfo *referer)
{
static methodinfo *m_parseAnnotations = NULL;
utf *utf_parseAnnotations = NULL;
*******************************************************************************/
-java_objectarray* reflect_get_parameterannotations(
+java_handle_objectarray_t* reflect_get_parameterannotations(
java_handle_t *parameterAnnotations,
int32_t slot,
java_lang_Class *declaringClass,
/* get parameter count */
- c = (classinfo *)declaringClass;
+ c = LLNI_classinfo_unwrap(declaringClass);
m = &(c->methods[slot]);
numParameters = method_get_parametercount(m);
}
}
- return (java_objectarray*)vm_call_method(
+ return (java_handle_objectarray_t*)vm_call_method(
m_parseParameterAnnotations, NULL, parameterAnnotations,
constantPool, declaringClass, numParameters);
}