#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Constructor.h"
// FIXME
-extern "C" {
-#include "native/include/java_lang_reflect_VMConstructor.h"
-}
+//#include "native/include/java_lang_reflect_VMConstructor.h"
-#include "native/vm/reflect.h"
+#include "native/vm/reflection.hpp"
#include "vm/string.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/utf8.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal },
- { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes },
- { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes },
- { (char*) "construct", (char*) "([Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_construct },
- { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getSignature },
-#if defined(ENABLE_ANNOTATIONS)
- { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations },
- { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMConstructor_init ************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-extern "C" {
-void _Jv_java_lang_reflect_VMConstructor_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/reflect/VMConstructor");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: getModifiersInternal
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
-
- m = &(c->methods[slot]);
-
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
return m->flags;
}
* Method: getParameterTypes
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_handle_objectarray_t* hoa = method_get_parametertypearray(m);
- m = &(c->methods[slot]);
-
- return method_get_parametertypearray(m);
+ return (jobjectArray) hoa;
}
* Method: getExceptionTypes
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
- m = &(c->methods[slot]);
+ java_handle_objectarray_t* hoa = method_get_exceptionarray(m);
- return method_get_exceptionarray(m);
+ return (jobjectArray) hoa;
}
* Method: construct
* Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, java_lang_reflect_VMConstructor *_this, java_handle_objectarray_t *args)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, jobject _this, jobjectArray args)
{
- classinfo *c;
- int32_t slot;
- java_lang_reflect_Constructor *rc;
- int32_t override;
- methodinfo *m;
- java_handle_t *o;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_lang_reflect_VMConstructor rvmc(_this);
+ java_lang_reflect_Constructor rc(rvmc.get_cons());
+ methodinfo* m = rvmc.get_method();
+ int32_t override = rc.get_flag();
- LLNI_field_get_ref(_this, cons, rc);
- LLNI_field_get_val(rc, flag, override);
+ java_handle_t* o = java_lang_reflect_Constructor::new_instance(m, (java_handle_objectarray_t*) args, override);
- m = &(c->methods[slot]);
-
- o = reflect_constructor_newinstance(m, args, override);
-
- return (java_lang_Object *) o;
+ return (jobject) o;
}
* Method: getSignature
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
java_handle_t *o;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
-
- m = &(c->methods[slot]);
if (m->signature == NULL)
return NULL;
/* In error case o is NULL. */
- return (java_lang_String *) o;
+ return (jstring) o;
}
* Parses the annotations (if they aren't parsed yet) and stores them into
* the declaredAnnotations map and return this map.
*/
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, jobject _this)
{
- java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
- java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
- java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMConstructor rvmc(_this);
- LLNI_field_get_ref(_this, declaredAnnotations, declaredAnnotations);
+ java_handle_t* declaredAnnotations = rvmc.get_declaredAnnotations();
/* are the annotations parsed yet? */
if (declaredAnnotations == NULL) {
- LLNI_field_get_ref(_this, annotations, annotations);
- LLNI_field_get_ref(_this, clazz, declaringClass);
+ java_handle_bytearray_t* annotations = rvmc.get_annotations();
+ classinfo* declaringClass = rvmc.get_clazz();
+
+ classinfo *referer;
LLNI_class_get(_this, referer);
- declaredAnnotations = reflect_get_declaredannotations(annotations, (classinfo*) declaringClass, referer);
+ declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
- LLNI_field_set_ref(_this, declaredAnnotations, declaredAnnotations);
+ rvmc.set_declaredAnnotations(declaredAnnotations);
}
- return declaredAnnotations;
+ return (jobject) declaredAnnotations;
}
*
* Parses the parameter annotations and returns them in an 2 dimensional array.
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, jobject _this)
{
- java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */
- int32_t slot = -1; /* slot of the method */
- classinfo *c;
- methodinfo *m;
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMConstructor rvmc(_this);
+
+ java_handle_bytearray_t* parameterAnnotations = rvmc.get_parameterAnnotations();
+ methodinfo* m = rvmc.get_method();
- LLNI_field_get_ref(_this, parameterAnnotations, parameterAnnotations);
- LLNI_field_get_val(_this, slot, slot);
- LLNI_field_get_cls(_this, clazz, c);
- m = &(c->methods[slot]);
+ classinfo* referer;
+ LLNI_class_get((java_lang_reflect_VMConstructor*) _this, referer);
- LLNI_class_get(_this, referer);
+ java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer);
- return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, m, referer);
+ return (jobjectArray) oa;
}
#endif
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal },
+ { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes },
+ { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes },
+ { (char*) "construct", (char*) "([Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_construct },
+ { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getSignature },
+#if defined(ENABLE_ANNOTATIONS)
+ { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations },
+ { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMConstructor_init ************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+extern "C" {
+void _Jv_java_lang_reflect_VMConstructor_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/reflect/VMConstructor");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where