Signed-off-by: Tomek Grabiec <[email protected]>
---
 include/vm/object.h |    6 ++++++
 vm/jni-interface.c  |   18 +++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/include/vm/object.h b/include/vm/object.h
index adc870a..8d7ad3e 100644
--- a/include/vm/object.h
+++ b/include/vm/object.h
@@ -132,6 +132,12 @@ array_get_field_byte(struct vm_object *obj, int index)
 }
 
 static inline void
+array_set_field_byte(struct vm_object *obj, int index, uint8_t value)
+{
+       *(uint8_t *) &obj->fields[index * get_vmtype_size(J_BYTE)] = value;
+}
+
+static inline void
 array_set_field_ptr(struct vm_object *obj, int index, void *value)
 {
        *(void **) &obj->fields[index * get_vmtype_size(J_REFERENCE)] = value;
diff --git a/vm/jni-interface.c b/vm/jni-interface.c
index 29a5d94..62f82e1 100644
--- a/vm/jni-interface.c
+++ b/vm/jni-interface.c
@@ -565,6 +565,22 @@ vm_jni_get_byte_array_elements(struct vm_jni_env *env, 
jobject array,
        return result;
 }
 
+static void
+vm_jni_release_byte_array_elements(struct vm_jni_env *env, jobject array,
+                                  jbyte *elems, jint mode)
+{
+       if (!vm_class_is_array_class(array->class) ||
+           vm_class_get_array_element_class(array->class) != vm_byte_class)
+               return;
+
+       if (mode == 0 || mode == JNI_COMMIT) { /* copy back */
+               for (long i = 0; i < array->array_length; i++)
+                       array_set_field_byte(array, i, elems[i]);
+       }
+
+       if (mode == 0 || mode == JNI_ABORT) /* free buffer */
+               free(elems);
+}
 
 /*
  * The JNI native interface table.
@@ -840,7 +856,7 @@ void *vm_jni_native_interface[] = {
        /* 190 */
        NULL, /* GetDoubleArrayElements */
        NULL, /* ReleaseBooleanArrayElements */
-       NULL, /* ReleaseByteArrayElements */
+       vm_jni_release_byte_array_elements,
        NULL, /* ReleaseCharArrayElements */
        NULL, /* ReleaseShortArrayElements */
 
-- 
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

Reply via email to