Signed-off-by: Tomek Grabiec <[email protected]>
---
include/vm/object.h | 6 ++++++
vm/jni-interface.c | 26 +++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/include/vm/object.h b/include/vm/object.h
index c293c41..adc870a 100644
--- a/include/vm/object.h
+++ b/include/vm/object.h
@@ -125,6 +125,12 @@ array_get_field_char(struct vm_object *obj, int index)
return *(uint16_t *) &obj->fields[index * get_vmtype_size(J_CHAR)];
}
+static inline uint8_t
+array_get_field_byte(struct vm_object *obj, int index)
+{
+ return *(uint8_t *) &obj->fields[index * get_vmtype_size(J_BYTE)];
+}
+
static inline void
array_set_field_ptr(struct vm_object *obj, int index, void *value)
{
diff --git a/vm/jni-interface.c b/vm/jni-interface.c
index eb8468e..29a5d94 100644
--- a/vm/jni-interface.c
+++ b/vm/jni-interface.c
@@ -542,6 +542,30 @@ static jobject vm_jni_get_object_field(struct vm_jni_env
*env, jobject object,
return field_get_object(object, field);
}
+static jbyte *
+vm_jni_get_byte_array_elements(struct vm_jni_env *env, jobject array,
+ jboolean *is_copy)
+{
+ jbyte *result;
+
+ if (!vm_class_is_array_class(array->class) ||
+ vm_class_get_array_element_class(array->class) != vm_byte_class)
+ return NULL;
+
+ result = malloc(sizeof(jbyte) * array->array_length);
+ if (!result)
+ return NULL;
+
+ for (long i = 0; i < array->array_length; i++)
+ result[i] = array_get_field_byte(array, i);
+
+ if (is_copy)
+ *is_copy = JNI_TRUE;
+
+ return result;
+}
+
+
/*
* The JNI native interface table.
* See: http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/functions.html
@@ -804,7 +828,7 @@ void *vm_jni_native_interface[] = {
NULL, /* NewFloatArray */
NULL, /* NewDoubleArray */
NULL, /* GetBooleanArrayElements */
- NULL, /* GetByteArrayElements */
+ vm_jni_get_byte_array_elements,
/* 185 */
NULL, /* GetCharArrayElements */
--
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