Signed-off-by: Tomek Grabiec <[email protected]>
---
vm/jni-interface.c | 76 +++++++++++++++++++++++++++++++--------------------
1 files changed, 46 insertions(+), 30 deletions(-)
diff --git a/vm/jni-interface.c b/vm/jni-interface.c
index ea255dc..ce36470 100644
--- a/vm/jni-interface.c
+++ b/vm/jni-interface.c
@@ -52,6 +52,31 @@
if (!vm_object_is_instance_of((x), vm_java_lang_Class)) \
return NULL;
+static jfieldID
+vm_jni_common_get_field_id(jclass clazz, const char *name, const char *sig)
+{
+ struct vm_class *class;
+ struct vm_field *fb;
+
+ check_null(clazz);
+ check_class_object(clazz);
+
+ class = vm_class_get_class_from_class_object(clazz);
+ check_null(class);
+
+ vm_class_ensure_init(class);
+ if (exception_occurred())
+ return NULL;
+
+ fb = vm_class_get_field(class, name, sig);
+ if (!fb) {
+ signal_new_exception(vm_java_lang_NoSuchFieldError, NULL);
+ return NULL;
+ }
+
+ return fb;
+}
+
static void vm_jni_destroy_java_vm(void)
{
NOT_IMPLEMENTED;
@@ -158,27 +183,14 @@ vm_jni_get_field_id(struct vm_jni_env *env, jclass clazz,
const char *name,
const char *sig)
{
struct vm_field *fb;
- struct vm_class *class;
enter_vm_from_jni();
- check_null(clazz);
- check_class_object(clazz);
-
- class = vm_class_get_class_from_class_object(clazz);
- check_null(class);
+ fb = vm_jni_common_get_field_id(clazz, name, sig);
- vm_class_ensure_init(class);
- if (exception_occurred())
+ if (vm_field_is_static(fb))
return NULL;
- /* XXX: Make sure it's not static. */
- fb = vm_class_get_field(class, name, sig);
- if (!fb) {
- signal_new_exception(vm_java_lang_NoSuchFieldError, NULL);
- return NULL;
- }
-
return fb;
}
@@ -654,27 +666,31 @@ vm_jni_get_static_field_id(struct vm_jni_env *env, jclass
clazz,
const char *name, const char *sig)
{
struct vm_field *fb;
- struct vm_class *class;
enter_vm_from_jni();
- check_null(clazz);
- check_class_object(clazz);
-
- class = vm_class_get_class_from_class_object(clazz);
- check_null(class);
+ fb = vm_jni_common_get_field_id(clazz, name, sig);
- vm_class_ensure_init(class);
- if (exception_occurred())
+ if (!vm_field_is_static(fb))
return NULL;
- fb = vm_class_get_field(class, name, sig);
- if (!fb) {
- signal_new_exception(vm_java_lang_NoSuchFieldError, NULL);
- return NULL;
- }
+ return fb;
+}
- if (!vm_field_is_static(fb))
+static jfieldID
+vm_jni_get_static_double_field_id(struct vm_jni_env *env, jclass clazz,
+ const char *name, const char *sig)
+{
+ struct vm_field *fb;
+ struct vm_class *class;
+
+ enter_vm_from_jni();
+
+ fb = vm_jni_common_get_field(clazz, name, sig);
+ if (!fb)
+ return;
+
+ if (!vm_field_is_static(fb) || vm_field_type(fb) != J_DOUBLE)
return NULL;
return fb;
@@ -899,7 +915,7 @@ void *vm_jni_native_interface[] = {
NULL, /* GetStaticIntField */
NULL, /* GetStaticLongField */
NULL, /* GetStaticFloatField */
- NULL, /* GetStaticDoubleField */
+ vm_jni_get_static_double_field,
NULL, /* SetStaticObjectField */
/* 155 */
--
1.6.0.6
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel