summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5oImp.c
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/jni/h5oImp.c')
-rw-r--r--java/src/jni/h5oImp.c57
1 files changed, 14 insertions, 43 deletions
diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c
index b49a3e9..a52a905 100644
--- a/java/src/jni/h5oImp.c
+++ b/java/src/jni/h5oImp.c
@@ -378,15 +378,16 @@ H5O_iterate_cb
(hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data)
{
cb_wrapper *wrapper = (cb_wrapper *)cb_data;
- jmethodID constructor, mid;
+ jmethodID mid;
jobject cb_info_t = NULL;
jobject visit_callback = wrapper->visit_callback;
+ jobject ret_obj = NULL;
jobject hdrinfobuf;
jobject ihinfobuf1;
jobject ihinfobuf2;
jstring str;
JNIEnv *cbenv = NULL;
- jclass cls;
+ jclass cbcls;
jvalue args[12];
void *op_data = (void *)wrapper->op_data;
jint status = FAIL;
@@ -396,10 +397,10 @@ H5O_iterate_cb
H5_JNI_FATAL_ERROR(CBENVONLY, "H5O_iterate_cb: failed to attach current thread to JVM");
}
- if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+ if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_t;)I")))
+ if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_t;)I")))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
@@ -417,41 +418,21 @@ H5O_iterate_cb
args[9].j = (jlong)info->hdr.mesg.shared;
/* Get a reference to the H5_hdr_info_t class */
- if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t")))
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
-
- /* Get a reference to the constructor; the name is <init> */
- if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(IIIIJJJJJJ)V")))
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
-
- if (NULL == (hdrinfobuf = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) {
- HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_hdr_info_t: Creation failed\n");
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- }
+ CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args, ret_obj);
+ hdrinfobuf = ret_obj;
args[0].j = (jlong)info->meta_size.obj.index_size;
args[1].j = (jlong)info->meta_size.obj.heap_size;
/* Get a reference to the H5_ih_info_t class */
- if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t")))
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
-
- /* Get a reference to the constructor; the name is <init> */
- if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJ)V")))
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
-
- if (NULL == (ihinfobuf1 = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) {
- HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n");
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- }
+ CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj);
+ ihinfobuf1 = ret_obj;
args[0].j = (jlong)info->meta_size.attr.index_size;
args[1].j = (jlong)info->meta_size.attr.heap_size;
- if (NULL == (ihinfobuf2 = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) {
- HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n");
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- }
+ CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj);
+ ihinfobuf2 = ret_obj;
args[0].j = (jlong)info->fileno;
args[1].j = (jlong)info->addr;
@@ -467,17 +448,7 @@ H5O_iterate_cb
args[11].l = ihinfobuf2;
/* Get a reference to the H5O_info_t class */
- if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t")))
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
-
- /* Get a reference to the constructor; the name is <init> */
- if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V")))
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
-
- if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) {
- HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_info_t: Creation failed\n");
- CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- }
+ CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, cb_info_t) ;
status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data);
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
@@ -639,7 +610,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment
if (buf_size) {
if (NULL == (oComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
- H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer");
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer");
if ((status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size + 1)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
@@ -684,7 +655,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name
if (buf_size) {
if (NULL == (objComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
- H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment");
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment");
if ((status = H5Oget_comment_by_name((hid_t)loc_id, objName, objComment, (size_t)buf_size + 1, (hid_t)access_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);