summaryrefslogtreecommitdiffstats
path: root/java/src/jni
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-08-21 13:23:12 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-08-21 13:23:12 (GMT)
commit3537a81e35b64903bcafd92a411cd1ca02ce4f2b (patch)
treed6e7d13a89ce996f540f9b804046e38e2c0a63ee /java/src/jni
parentc9b8f6b44b0fb803047f5445e15c4137d7a4e630 (diff)
downloadhdf5-3537a81e35b64903bcafd92a411cd1ca02ce4f2b.zip
hdf5-3537a81e35b64903bcafd92a411cd1ca02ce4f2b.tar.gz
hdf5-3537a81e35b64903bcafd92a411cd1ca02ce4f2b.tar.bz2
HDFFV-10536 Convert iterator callbacks from global to stack var
Diffstat (limited to 'java/src/jni')
-rw-r--r--java/src/jni/h5Imp.c1
-rw-r--r--java/src/jni/h5aImp.c22
-rw-r--r--java/src/jni/h5dImp.c19
-rw-r--r--java/src/jni/h5eImp.c18
-rw-r--r--java/src/jni/h5fImp.c7
-rw-r--r--java/src/jni/h5gImp.c1
-rw-r--r--java/src/jni/h5iImp.c1
-rw-r--r--java/src/jni/h5lImp.c29
-rw-r--r--java/src/jni/h5oImp.c21
-rw-r--r--java/src/jni/h5pImp.c30
-rw-r--r--java/src/jni/h5plImp.c1
-rw-r--r--java/src/jni/h5rImp.c1
-rw-r--r--java/src/jni/h5sImp.c1
-rw-r--r--java/src/jni/h5tImp.c1
-rw-r--r--java/src/jni/h5util.c1
15 files changed, 94 insertions, 60 deletions
diff --git a/java/src/jni/h5Imp.c b/java/src/jni/h5Imp.c
index 2eeb075..1ad6b17 100644
--- a/java/src/jni/h5Imp.c
+++ b/java/src/jni/h5Imp.c
@@ -36,7 +36,6 @@ extern "C" {
#include "h5Imp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index c0dc182..aba2240 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -29,7 +29,11 @@ extern "C" {
#include "h5aImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
+
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
#ifdef __cplusplus
#define CBENVPTR (cbenv)
@@ -53,7 +57,8 @@ static herr_t H5AwriteVL_asstr (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjec
static herr_t H5AwriteVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
static herr_t H5AreadVL_asstr (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
static herr_t H5AreadVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
-static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *op_data);
+
+static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data);
/*
@@ -1138,7 +1143,7 @@ Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist
static herr_t
H5A_iterate_cb
- (hid_t g_id, const char *name, const H5A_info_t *info, void *op_data) {
+ (hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data) {
JNIEnv *cbenv;
jint status = -1;
jclass cls;
@@ -1147,6 +1152,9 @@ H5A_iterate_cb
jmethodID constructor;
jvalue args[4];
jobject cb_info_t = NULL;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) {
cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback);
@@ -1195,14 +1203,14 @@ Java_hdf_hdf5lib_H5_H5Aiterate
hsize_t start_idx = (hsize_t)idx;
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL");
} /* end if */
else {
- status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)op_data);
+ status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper);
if (status < 0)
h5libraryError(env);
@@ -1224,9 +1232,9 @@ Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name
const char *lName;
hsize_t start_idx = (hsize_t)idx;
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL");
@@ -1234,7 +1242,7 @@ Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name
else {
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- status = H5Aiterate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)op_data, (hid_t)access_id);
+ status = H5Aiterate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c
index 205e9fb..f984948 100644
--- a/java/src/jni/h5dImp.c
+++ b/java/src/jni/h5dImp.c
@@ -30,7 +30,11 @@ extern "C" {
#include "h5dImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
+
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
#ifdef __cplusplus
#ifdef _WINDOWS
@@ -1362,13 +1366,9 @@ Java_hdf_hdf5lib_H5_H5DwriteVL
isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
}
if (isStr == 0 || isComplex>0 || isVlenStr) {
- h5unimplemented(env, "H5DwriteVL: VL types, which are not string type, not implemented");
- status = -1;
-#ifdef notdef
status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
-#endif
}
else if (isStr > 0) {
status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
@@ -1892,7 +1892,7 @@ Java_hdf_hdf5lib_H5_H5Dset_1extent
static herr_t
H5D_iterate_cb
- (void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *op_data) {
+ (void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *cb_data) {
JNIEnv *cbenv;
jint status;
jclass cls;
@@ -1900,6 +1900,9 @@ H5D_iterate_cb
jbyteArray elemArray;
jlongArray pointArray;
jsize size;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) {
JVMPTR->DetachCurrentThread(JVMPAR);
@@ -1962,9 +1965,9 @@ Java_hdf_hdf5lib_H5_H5Diterate
herr_t status = -1;
jboolean isCopy;
jbyte *buffP;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Diterate: op_data is NULL");
@@ -1981,7 +1984,7 @@ Java_hdf_hdf5lib_H5_H5Diterate
h5JNIFatalError(env, "H5Diterate: buf not pinned");
} /* end if */
else {
- status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)op_data);
+ status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)&wrapper);
if (status < 0) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT);
diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c
index 10a02b0..9c80461 100644
--- a/java/src/jni/h5eImp.c
+++ b/java/src/jni/h5eImp.c
@@ -40,7 +40,11 @@ extern "C" {
#include "h5eImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
+
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
#ifdef __cplusplus
#define CBENVPTR (cbenv)
@@ -60,7 +64,7 @@ extern jobject visit_callback;
/* Local Prototypes */
/********************/
-static herr_t H5E_walk_cb(int nindx, const H5E_error2_t *info, void *op_data);
+static herr_t H5E_walk_cb(int nindx, const H5E_error2_t *info, void *cb_data);
/*
* Class: hdf_hdf5lib_H5
@@ -475,7 +479,7 @@ Java_hdf_hdf5lib_H5_H5Eget_1num
static herr_t
H5E_walk_cb
- (int nindx, const H5E_error2_t *info, void *op_data)
+ (int nindx, const H5E_error2_t *info, void *cb_data)
{
JNIEnv *cbenv;
jint status = -1;
@@ -485,6 +489,9 @@ H5E_walk_cb
jmethodID constructor;
jvalue args[7];
jobject cb_info_t = NULL;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) {
cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback);
@@ -532,13 +539,14 @@ JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Ewalk2
(JNIEnv *env, jclass cls, jlong stk_id, jlong direction, jobject callback_op, jobject op_data)
{
+ cb_wrapper wrapper = {callback_op, op_data};
+
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Ewalk2: op_data or callback_op is NULL");
} /* end if */
- else if (H5Ewalk2(stk_id, (H5E_direction_t)direction, (H5E_walk2_t)H5E_walk_cb, (void*)op_data) < 0)
+ else if (H5Ewalk2(stk_id, (H5E_direction_t)direction, (H5E_walk2_t)H5E_walk_cb, (void*)&wrapper) < 0)
h5libraryError(env);
} /* end iJava_hdf_hdf5lib_H5_H5Ewalk2f */
diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c
index 8cf5252..9d68290 100644
--- a/java/src/jni/h5fImp.c
+++ b/java/src/jni/h5fImp.c
@@ -29,7 +29,6 @@ extern "C" {
#include "h5util.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
@@ -541,7 +540,7 @@ Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write
- (JNIEnv *env, jclass cls, jlong file_id)
+ (JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Fstart_swmr_write((hid_t)file_id) < 0)
h5libraryError(env);
@@ -554,7 +553,7 @@ Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging
- (JNIEnv *env, jclass cls, jlong file_id)
+ (JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Fstart_mdc_logging((hid_t)file_id) < 0)
h5libraryError(env);
@@ -580,7 +579,7 @@ Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status
- (JNIEnv *env, jclass cls, jlong file_id, jbooleanArray mdc_logging_status)
+ (JNIEnv *env, jclass cls, jlong file_id, jbooleanArray mdc_logging_status)
{
hbool_t is_enabled;
hbool_t is_currently_logging;
diff --git a/java/src/jni/h5gImp.c b/java/src/jni/h5gImp.c
index 41ec382..42c042a 100644
--- a/java/src/jni/h5gImp.c
+++ b/java/src/jni/h5gImp.c
@@ -30,7 +30,6 @@ extern "C" {
#include "h5gImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5iImp.c b/java/src/jni/h5iImp.c
index 47574ca..b8bd1cd 100644
--- a/java/src/jni/h5iImp.c
+++ b/java/src/jni/h5iImp.c
@@ -28,7 +28,6 @@ extern "C" {
#include "h5iImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c
index f1734fd..e1ec3bd 100644
--- a/java/src/jni/h5lImp.c
+++ b/java/src/jni/h5lImp.c
@@ -28,13 +28,17 @@ extern "C" {
#include "h5lImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
+
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info_t *info, void *op_data);
+static herr_t H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info_t *info, void *cb_data);
/*
* Class: hdf_hdf5lib_H5
@@ -541,7 +545,7 @@ Java_hdf_hdf5lib_H5_H5Lmove
static herr_t
H5L_iterate_cb
- (hid_t g_id, const char *name, const H5L_info_t *info, void *op_data)
+ (hid_t g_id, const char *name, const H5L_info_t *info, void *cb_data)
{
JNIEnv *cbenv;
jint status;
@@ -551,6 +555,9 @@ H5L_iterate_cb
jmethodID constructor;
jvalue args[5];
jobject cb_info_t = NULL;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) {
cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback);
@@ -600,15 +607,15 @@ Java_hdf_hdf5lib_H5_H5Lvisit
jobject callback_op, jobject op_data)
{
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Lvisit: op_data or callback_op is NULL");
} /* end if */
else {
- status = H5Lvisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data);
+ status = H5Lvisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper);
if (status < 0)
h5libraryError(env);
} /* end else */
@@ -628,9 +635,9 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name
{
herr_t status = -1;
const char *lName;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Lvisit_by_name: op_data or callback_op is NULL");
@@ -638,7 +645,7 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name
else {
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- status = H5Lvisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id);
+ status = H5Lvisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
@@ -662,15 +669,15 @@ Java_hdf_hdf5lib_H5_H5Literate
{
hsize_t start_idx = (hsize_t)idx;
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Literate: op_data or callback_op is NULL");
} /* end if */
else {
- status = H5Literate((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data);
+ status = H5Literate((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper);
if (status < 0)
h5libraryError(env);
@@ -694,7 +701,7 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name
const char *lName;
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
+ cb_wrapper wrapper = {callback_op, op_data};
if ((op_data == NULL) || (callback_op == NULL)) {
h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL");
@@ -702,7 +709,7 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name
else {
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- status = H5Literate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id);
+ status = H5Literate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c
index 6093e46..1de505a 100644
--- a/java/src/jni/h5oImp.c
+++ b/java/src/jni/h5oImp.c
@@ -27,13 +27,17 @@ extern "C" {
#include "h5oImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
+
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *op_data);
+static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data);
/*
* Class: hdf_hdf5lib_H5
@@ -330,7 +334,7 @@ Java_hdf_hdf5lib_H5_H5Olink
static herr_t
H5O_iterate_cb
- (hid_t g_id, const char *name, const H5O_info_t *info, void *op_data)
+ (hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data)
{
JNIEnv *cbenv;
jint status = -1;
@@ -343,6 +347,9 @@ H5O_iterate_cb
jobject ihinfobuf1;
jobject ihinfobuf2;
jobject cb_info_t = NULL;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) {
/* printf("JNI H5O_iterate_cb error: AttachCurrentThread failed\n"); */
@@ -448,9 +455,9 @@ Java_hdf_hdf5lib_H5_H5Ovisit
jobject callback_op, jobject op_data, jint fields)
{
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Ovisit: op_data is NULL");
@@ -459,7 +466,7 @@ Java_hdf_hdf5lib_H5_H5Ovisit
h5nullArgument(env, "H5Ovisit: callback_op is NULL");
} /* end if */
else {
- status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (unsigned)fields);
+ status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)&wrapper, (unsigned)fields);
if (status < 0)
h5libraryError(env);
@@ -480,9 +487,9 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name
{
herr_t status = -1;
const char *lName;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Ovisit_by_name: op_data is NULL");
@@ -495,7 +502,7 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name
else {
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- status = H5Ovisit_by_name2((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (unsigned)fields, (hid_t)access_id);
+ status = H5Ovisit_by_name2((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)&wrapper, (unsigned)fields, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c
index 3ff7436..e6d1be8 100644
--- a/java/src/jni/h5pImp.c
+++ b/java/src/jni/h5pImp.c
@@ -27,7 +27,6 @@ extern "C" {
#include "h5pImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
extern jobject copy_callback;
extern jobject close_callback;
extern jobject create_callback;
@@ -36,6 +35,11 @@ extern jobject get_callback;
extern jobject set_callback;
extern jobject delete_callback;
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
+
/********************/
/* Local Prototypes */
/********************/
@@ -52,7 +56,7 @@ static herr_t H5P_prp_get_func_cb(hid_t prop_id, const char *name, size_t size,
static herr_t H5P_prp_set_func_cb(hid_t prop_id, const char *name, size_t size, void *value);
static herr_t H5P_prp_delete_func_cb(hid_t prop_id, const char *name, size_t size, void *value);
-static herr_t H5P_iterate_cb(hid_t prop_id, const char *name, void *op_data);
+static herr_t H5P_iterate_cb(hid_t prop_id, const char *name, void *cb_data);
/*
* Class: hdf_hdf5lib_H5
@@ -5042,7 +5046,7 @@ H5P_cls_copy_cb
} /* end if */
JVMPTR->DetachCurrentThread(JVMPAR);
return (herr_t)status;
-} /* end H5P_cls_ccopy_cb */
+} /* end H5P_cls_copy_cb */
static herr_t
H5P_cls_close_cb
@@ -5158,13 +5162,16 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options
static herr_t
H5D_append_cb
- (hid_t dataset_id, hsize_t *cur_dims, void *op_data)
+ (hid_t dataset_id, hsize_t *cur_dims, void *cb_data)
{
JNIEnv *cbenv;
jint status = -1;
jclass cls;
jmethodID mid;
jlongArray cur_dimsArray;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) {
JVMPTR->DetachCurrentThread(JVMPAR);
@@ -5199,9 +5206,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1append_1flush
(JNIEnv *env, jclass clss, jlong plist_id, jint ndims, jlongArray boundary, jobject callback_op, jobject op_data)
{
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Pset_append_flush: op_data is NULL");
@@ -5210,7 +5217,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1append_1flush
h5nullArgument(env, "H5Pset_append_flush: callback_op is NULL");
} /* end if */
else {
- status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t*)boundary, (H5D_append_cb_t)H5D_append_cb, (void*)op_data);
+ status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t*)boundary, (H5D_append_cb_t)H5D_append_cb, (void*)&wrapper);
if (status < 0)
h5libraryError(env);
@@ -5603,13 +5610,16 @@ Java_hdf_hdf5lib_H5_H5Pinsert2
static herr_t
H5P_iterate_cb
- (hid_t prop_id, const char *name, void *op_data)
+ (hid_t prop_id, const char *name, void *cb_data)
{
JNIEnv *cbenv;
jint status = -1;
jclass cls;
jmethodID mid;
jstring str;
+ cb_wrapper *wrapper = (cb_wrapper *)cb_data;
+ void *op_data = (void *)wrapper->op_data;
+ jobject visit_callback = wrapper->visit_callback;
/* fprintf(stderr, "\nJNI H5P_iterate_cb entered\n"); fflush(stderr); */
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) {
@@ -5656,9 +5666,9 @@ Java_hdf_hdf5lib_H5_H5Piterate
herr_t status = -1;
jint *theArray = NULL;
jboolean isCopy;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Piterate: op_data is NULL");
@@ -5668,7 +5678,7 @@ Java_hdf_hdf5lib_H5_H5Piterate
} /* end else if */
else {
if (idx == NULL) {
- status = H5Piterate((hid_t)prop_id, NULL, (H5P_iterate_t)H5P_iterate_cb, (void*)op_data);
+ status = H5Piterate((hid_t)prop_id, NULL, (H5P_iterate_t)H5P_iterate_cb, (void*)&wrapper);
} /* end if */
else {
theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR idx, &isCopy);
@@ -5676,7 +5686,7 @@ Java_hdf_hdf5lib_H5_H5Piterate
h5JNIFatalError(env, "H5Piterate: idx not pinned");
} /* end if */
else
- status = H5Piterate((hid_t)prop_id, (int*)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, (void*)op_data);
+ status = H5Piterate((hid_t)prop_id, (int*)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, (void*)&wrapper);
} /* end else */
if (status < 0) {
diff --git a/java/src/jni/h5plImp.c b/java/src/jni/h5plImp.c
index ffd5b7a..d551120 100644
--- a/java/src/jni/h5plImp.c
+++ b/java/src/jni/h5plImp.c
@@ -27,7 +27,6 @@ extern "C" {
#include "h5plImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c
index b250550..5f2b86d 100644
--- a/java/src/jni/h5rImp.c
+++ b/java/src/jni/h5rImp.c
@@ -27,7 +27,6 @@ extern "C" {
#include "h5rImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c
index 10f69eb..a4b4848 100644
--- a/java/src/jni/h5sImp.c
+++ b/java/src/jni/h5sImp.c
@@ -27,7 +27,6 @@ extern "C" {
#include "h5sImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c
index 7b4af56..307f1a5 100644
--- a/java/src/jni/h5tImp.c
+++ b/java/src/jni/h5tImp.c
@@ -30,7 +30,6 @@ extern "C" {
#include "h5tImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c
index 33dca7f..42f8a5c 100644
--- a/java/src/jni/h5util.c
+++ b/java/src/jni/h5util.c
@@ -33,7 +33,6 @@ hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */
int H5TOOLS_TEXT_BLOCK = 16; /* Number of elements on a line in a text export file */
JavaVM *jvm;
-jobject visit_callback;
jobject copy_callback;
jobject close_callback;
jobject create_callback;