summaryrefslogtreecommitdiffstats
path: root/java/src/jni
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/jni')
-rw-r--r--java/src/jni/CMakeLists.txt6
-rw-r--r--java/src/jni/Makefile.am2
-rw-r--r--java/src/jni/h5Constants.c43
-rw-r--r--java/src/jni/h5aImp.c1104
-rw-r--r--java/src/jni/h5aImp.h151
-rw-r--r--java/src/jni/h5dImp.c78
-rw-r--r--java/src/jni/h5dImp.h11
-rw-r--r--java/src/jni/h5fImp.c29
-rw-r--r--java/src/jni/h5fImp.h9
-rw-r--r--java/src/jni/h5vlImp.c206
-rw-r--r--java/src/jni/h5vlImp.h91
11 files changed, 1498 insertions, 232 deletions
diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt
index 7b95e0b..00c2b34 100644
--- a/java/src/jni/CMakeLists.txt
+++ b/java/src/jni/CMakeLists.txt
@@ -19,6 +19,7 @@ set (HDF5_JAVA_JNI_CSRCS
${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.c
${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.c
${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.c
+ ${HDF5_JAVA_JNI_SOURCE_DIR}/h5vlImp.c
${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.c
${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.c
)
@@ -40,6 +41,7 @@ set (HDF5_JAVA_JNI_CHDRS
${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.h
${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.h
${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.h
+ ${HDF5_JAVA_JNI_SOURCE_DIR}/h5vlImp.h
${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.h
${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.h
)
@@ -48,7 +50,9 @@ set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
########### JNI libraries always must be built shared ###############
add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JAVA_JNI_CHDRS})
-target_include_directories(${HDF5_JAVA_JNI_LIB_TARGET} PRIVATE ${HDF5_BINARY_DIR} ${HDF5_JAVA_JNI_SOURCE_DIR})
+target_include_directories(${HDF5_JAVA_JNI_LIB_TARGET}
+ PRIVATE "${HDF5_BINARY_DIR};${HDF5_JAVA_JNI_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
+)
TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED)
target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${HDF5_LIBSH_TARGET})
set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni)
diff --git a/java/src/jni/Makefile.am b/java/src/jni/Makefile.am
index 6ded371..370b08b 100644
--- a/java/src/jni/Makefile.am
+++ b/java/src/jni/Makefile.am
@@ -34,7 +34,7 @@ libhdf5_java_la_LDFLAGS = -avoid-version -shared -export-dynamic -version-info $
# Source files for the library
libhdf5_java_la_SOURCES=exceptionImp.c h5Constants.c nativeData.c h5util.c h5Imp.c \
h5aImp.c h5dImp.c h5eImp.c h5fImp.c h5gImp.c h5iImp.c h5lImp.c h5oImp.c \
- h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5zImp.c
+ h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5vlImp.c h5zImp.c
# HDF5 Java (JNI) library depends on HDF5 Library.
libhdf5_java_la_LIBADD=$(LIBHDF5)
diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c
index fdec61a..e88fa55 100644
--- a/java/src/jni/h5Constants.c
+++ b/java/src/jni/h5Constants.c
@@ -21,8 +21,10 @@
extern "C" {
#endif /* __cplusplus */
-#include <jni.h>
#include "hdf5.h"
+#include <jni.h>
+#include <stdlib.h>
+#include "h5jni.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
@@ -352,6 +354,15 @@ Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1UPWARD(JNIEnv *env, jclass cls) { retu
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5E_1WRITEERROR(JNIEnv *env, jclass cls) { return H5E_WRITEERROR; }
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1IN_1PROGRESS(JNIEnv *env, jclass cls) { return H5ES_STATUS_IN_PROGRESS; }
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1SUCCEED(JNIEnv *env, jclass cls) { return H5ES_STATUS_SUCCEED; }
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1FAIL(JNIEnv *env, jclass cls) { return H5ES_STATUS_FAIL; }
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1CANCELED(JNIEnv *env, jclass cls) { return H5ES_STATUS_CANCELED; }
+
/* Java does not have unsigned native types */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
@@ -603,8 +614,6 @@ Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASET(JNIEnv *env, jclass cls) { return H5
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5I_1ATTR(JNIEnv *env, jclass cls) { return H5I_ATTR; }
JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_HDF5Constants_H5I_1REFERENCE(JNIEnv *env, jclass cls) { return H5I_REFERENCE; }
-JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5I_1VFL(JNIEnv *env, jclass cls) { return H5I_VFL; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5I_1VOL(JNIEnv *env, jclass cls) { return H5I_VOL; }
@@ -763,8 +772,14 @@ Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1ERROR(JNIEnv *env, jclass cls) { retu
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1FILTER(JNIEnv *env, jclass cls) { return H5PL_TYPE_FILTER; }
JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1VOL(JNIEnv *env, jclass cls) { return H5PL_TYPE_VOL; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1NONE(JNIEnv *env, jclass cls) { return H5PL_TYPE_NONE; }
+JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5PL_1FILTER_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_FILTER_PLUGIN; }
JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5PL_1VOL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_VOL_PLUGIN; }
+JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5PL_1ALL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_ALL_PLUGIN; }
JNIEXPORT jint JNICALL
@@ -1239,6 +1254,28 @@ JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); }
JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1NONE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_NONE; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_THREADSAFE; }
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls) { return H5VL_NATIVE; }
+JNIEXPORT jobject JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) { return (jstring)ENVPTR->NewStringUTF(ENVPAR H5VL_NATIVE_NAME); }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VALUE(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VALUE; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VERSION(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VERSION; }
+
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1INVALID(JNIEnv *env, jclass cls) { return H5_VOL_INVALID; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1NATIVE(JNIEnv *env, jclass cls) { return H5_VOL_NATIVE; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1RESERVED(JNIEnv *env, jclass cls) { return H5_VOL_RESERVED; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1MAX(JNIEnv *env, jclass cls) { return H5_VOL_MAX; }
+
+JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1ERROR(JNIEnv *env, jclass cls) { return H5Z_CB_ERROR; }
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index aba2240..e0ec4ca 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -60,6 +60,94 @@ static herr_t H5AreadVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectAr
static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data);
+/********************/
+/* Local Macros */
+/********************/
+
+#define PIN_BYTE_ARRAY() { \
+ if (isCriticalPinning) \
+ buffP = (jbyte*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
+ else \
+ buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); \
+}
+
+#define UNPIN_BYTE_ARRAY(mode) { \
+ if (isCriticalPinning) \
+ ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
+ else \
+ ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, mode); \
+}
+
+#define PIN_SHORT_ARRAY() { \
+ if (isCriticalPinning) \
+ buffP = (jshort*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
+ else \
+ buffP = ENVPTR->GetShortArrayElements(ENVPAR buf, &isCopy); \
+}
+
+#define UNPIN_SHORT_ARRAY(mode) { \
+ if (isCriticalPinning) \
+ ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
+ else \
+ ENVPTR->ReleaseShortArrayElements(ENVPAR buf, buffP, mode); \
+}
+
+#define PIN_INT_ARRAY() { \
+ if (isCriticalPinning) \
+ buffP = (jint*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
+ else \
+ buffP = ENVPTR->GetIntArrayElements(ENVPAR buf, &isCopy); \
+}
+
+#define UNPIN_INT_ARRAY(mode) { \
+ if (isCriticalPinning) \
+ ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
+ else \
+ ENVPTR->ReleaseIntArrayElements(ENVPAR buf, buffP, mode); \
+}
+
+#define PIN_LONG_ARRAY() { \
+ if (isCriticalPinning) \
+ buffP = (jlong*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
+ else \
+ buffP = ENVPTR->GetLongArrayElements(ENVPAR buf,&isCopy); \
+}
+
+#define UNPIN_LONG_ARRAY(mode) { \
+ if (isCriticalPinning) \
+ ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
+ else \
+ ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, mode); \
+}
+
+#define PIN_FLOAT_ARRAY() { \
+ if (isCriticalPinning) \
+ buffP = (jfloat*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
+ else \
+ buffP = ENVPTR->GetFloatArrayElements(ENVPAR buf, &isCopy); \
+}
+
+#define UNPIN_FLOAT_ARRAY(mode) { \
+ if (isCriticalPinning) \
+ ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
+ else \
+ ENVPTR->ReleaseFloatArrayElements(ENVPAR buf, buffP, mode); \
+}
+
+#define PIN_DOUBLE_ARRAY() { \
+ if (isCriticalPinning) \
+ buffP = (jdouble*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
+ else \
+ buffP = ENVPTR->GetDoubleArrayElements(ENVPAR buf, &isCopy); \
+}
+
+#define UNPIN_DOUBLE_ARRAY(mode) { \
+ if (isCriticalPinning) \
+ ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
+ else \
+ ENVPTR->ReleaseDoubleArrayElements(ENVPAR buf, buffP, mode); \
+}
+
/*
* Class: hdf_hdf5lib_H5
@@ -129,36 +217,129 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1idx
return (jlong)attr_id;
} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1idx */
+static htri_t
+H5Tdetect_variable_str
+ (hid_t tid) {
+ htri_t ret_val = 0;
+
+ if (H5Tget_class(tid) == H5T_COMPOUND) {
+ unsigned i;
+ unsigned nm = (unsigned)H5Tget_nmembers(tid);
+ for(i = 0; i < nm; i++) {
+ htri_t status = 0;
+ hid_t mtid = 0;
+ if((mtid = H5Tget_member_type(tid, i)) < 0)
+ return -1; /* exit immediately on error */
+ if((status = H5Tdetect_variable_str(mtid)) < 0)
+ return status; /* exit immediately on error */
+ ret_val |= status;
+ H5Tclose (mtid);
+ } /* end for */
+ } /* end if */
+ else
+ ret_val = H5Tis_variable_str(tid);
+
+ return ret_val;
+} /* end H5Tdetect_variable_str */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread
+ * Signature: (JJ[BZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jbyte *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL) {
+ h5nullArgument( env,"H5Aread: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Aread: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Aread: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_BYTE_ARRAY();
+
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Aread: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP);
+ if (status < 0) {
+ UNPIN_BYTE_ARRAY(JNI_ABORT);
+ h5libraryError(env);
+ } /* end if */
+ else {
+ UNPIN_BYTE_ARRAY(0); /* update java buffer for return */
+ } /* end else */
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Aread */
+
/*
* Class: hdf_hdf5lib_H5
* Method: H5Awrite
- * Signature: (JJ[B)I
+ * Signature: (JJ[BZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Awrite
- (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf)
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
- jbyte *byteP;
+ jbyte *buffP;
jboolean isCopy;
+ htri_t data_class;
if (buf == NULL) {
h5nullArgument( env,"H5Awrite: buf is NULL");
} /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Awrite: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite: buf does not support variable length type");
+ } /* end else if */
else {
- byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy);
- if (byteP == NULL) {
- h5JNIFatalError(env,"H5Awrite: buf is not pinned");
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Awrite: H5Tdetect_variable_str() failed");
} /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite: buf does not support variable length type");
+ } /* end else if */
else {
- status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, byteP);
+ PIN_BYTE_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Awrite: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- /* free the buffer without copying back */
- ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT);
+ UNPIN_BYTE_ARRAY(JNI_ABORT); /* no need to update buffer */
- if (status < 0)
- h5libraryError(env);
- }
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+ } /* end else */
} /* end else */
return (jint)status;
@@ -166,190 +347,653 @@ Java_hdf_hdf5lib_H5_H5Awrite
/*
* Class: hdf_hdf5lib_H5
- * Method: H5Aread
- * Signature: (JJ[B)I
+ * Method: H5Aread_short
+ * Signature: (JJ[SZ)I
*/
JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5Aread
- (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf)
+Java_hdf_hdf5lib_H5_H5Aread_1short
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
- jbyte *byteP;
+ jshort *buffP;
jboolean isCopy;
+ htri_t data_class;
if (buf == NULL) {
- h5nullArgument( env,"H5Aread: buf is NULL");
+ h5nullArgument(env, "H5Aread_short: buf is NULL");
} /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Aread: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_short: buf does not support variable length type");
+ } /* end else if */
else {
- byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy);
- if (byteP == NULL) {
- h5JNIFatalError( env,"H5Aread: buf is not pinned");
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Aread_short: H5Tdetect_variable_str() failed");
} /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_short: buf does not support variable length type");
+ } /* end else if */
else {
- status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, byteP);
- if (status < 0) {
- ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT);
- h5libraryError(env);
+ PIN_SHORT_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Aread_short: buf not pinned");
} /* end if */
- else {
- ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, 0);
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP);
+
+ if (status < 0) {
+ UNPIN_SHORT_ARRAY(JNI_ABORT);
+ h5libraryError(env);
+ } /* end if */
+ else {
+ UNPIN_SHORT_ARRAY(0);
+ } /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
-} /* end Java_hdf_hdf5lib_H5_H5Aread */
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1short */
/*
* Class: hdf_hdf5lib_H5
- * Method: H5AwriteVL
- * Signature: (JJ[Ljava/lang/String;)I
+ * Method: H5Awrite_short
+ * Signature: (JJ[SZ)I
*/
JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5AwriteVL
- (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf)
+Java_hdf_hdf5lib_H5_H5Awrite_1short
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning)
{
- herr_t status = -1;
- htri_t isStr = 0;
- htri_t isVlenStr = 0;
- htri_t isComplex = 0;
+ herr_t status = -1;
+ jshort *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL ) {
+ h5nullArgument(env, "H5Awrite_short: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_short: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_short: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_short: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_short: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_SHORT_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Awrite_short: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP);
+
+ UNPIN_SHORT_ARRAY(JNI_ABORT);
+
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1short */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_int
+ * Signature: (JJ[IZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1int
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jint *buffP;
+ jboolean isCopy;
+ htri_t data_class;
if (buf == NULL) {
- h5nullArgument(env, "H5AwriteVL: buf is NULL");
+ h5nullArgument(env, "H5Aread_int: buf is NULL");
} /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Aread_int: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_int: buf does not support variable length type");
+ } /* end else if */
else {
- isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
- if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
- unsigned i;
- int nm = H5Tget_nmembers(mem_type_id);
- for(i = 0; i <nm; i++) {
- hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
- isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
- H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
- H5Tclose(nested_tid);
- }
- }
- else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
- isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
- }
- if (isStr == 0 || isComplex>0 || isVlenStr) {
- status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
- }
- else if (isStr > 0) {
- status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
- }
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Aread_int: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_int: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_INT_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Aread_int: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP);
+
+ if (status < 0) {
+ UNPIN_INT_ARRAY(JNI_ABORT);
+ h5libraryError(env);
+ } /* end if */
+ else {
+ UNPIN_INT_ARRAY(0);
+ } /* end else */
+ } /* end else */
+ } /* end else */
} /* end else */
return (jint)status;
-} /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1int */
-herr_t
-H5AwriteVL_str
- (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_int
+ * Signature: (JJ[IZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1int
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning)
{
- herr_t status = -1;
- char **wdata;
- jsize size;
- jint i;
+ herr_t status = -1;
+ jint *buffP;
+ jboolean isCopy;
+ htri_t data_class;
- size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf);
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Awrite_int: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_int: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_int: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_int: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_int: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_INT_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Awrite_int: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*));
- if (!wdata) {
- h5JNIFatalError(env, "H5AwriteVL_str: cannot allocate buffer");
+ UNPIN_INT_ARRAY(JNI_ABORT);
+
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1int */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_long
+ * Signature: (JJ[JZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1long
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jlong *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Aread_long: buf is NULL");
} /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Aread_long: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_long: buf does not support variable length type");
+ } /* end else if */
else {
- HDmemset(wdata, 0, (size_t)size * sizeof(char*));
- for (i = 0; i < size; ++i) {
- jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i);
- if (obj != 0) {
- jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
- const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Aread_long: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_long: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_LONG_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Aread_long: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- if (utf8) {
- wdata[i] = (char*)HDmalloc((size_t)length + 1);
- if (wdata[i]) {
- HDmemset(wdata[i], 0, ((size_t)length + 1));
- HDstrncpy(wdata[i], utf8, (size_t)length);
- } /* end if */
+ if (status < 0) {
+ UNPIN_LONG_ARRAY(JNI_ABORT);
+ h5libraryError(env);
} /* end if */
+ else {
+ UNPIN_LONG_ARRAY(0);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+ } /* end else */
- ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
- ENVPTR->DeleteLocalRef(ENVPAR obj);
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1long */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_long
+ * Signature: (JJ[JZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1long
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jlong *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Awrite_long: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_long: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_long: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_long: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_LONG_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Awrite_long: buf not pinned");
} /* end if */
- } /* end for (i = 0; i < size; ++i) */
+ else {
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- status = H5Awrite((hid_t)aid, (hid_t)tid, wdata);
+ UNPIN_LONG_ARRAY(JNI_ABORT);
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+ } /* end else */
+ } /* end else */
- for (i = 0; i < size; i++) {
- if(wdata[i]) {
- HDfree(wdata[i]);
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1long */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_float
+ * Signature: (JJ[FZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1float
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jfloat *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Aread_float: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Dread_float: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_float: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Aread_float: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_float: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_FLOAT_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Aread_float: buf not pinned");
} /* end if */
- } /* end for */
- HDfree(wdata);
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- if (status < 0)
- h5libraryError(env);
+ if (status < 0) {
+ UNPIN_FLOAT_ARRAY(JNI_ABORT);
+ h5libraryError(env);
+ } /* end if */
+ else {
+ UNPIN_FLOAT_ARRAY(0);
+ } /* end else */
+ } /* end else */
+ } /* end else */
} /* end else */
return (jint)status;
-}
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1float */
-herr_t
-H5AwriteVL_asstr
- (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_float
+ * Signature: (JJ[FZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1float
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning)
{
- char **strs;
- jstring jstr;
- jint i;
- jint n;
- hid_t sid;
- hsize_t dims[H5S_MAX_RANK];
- herr_t status = -1;
+ herr_t status = -1;
+ jfloat *buffP;
+ jboolean isCopy;
+ htri_t data_class;
- n = ENVPTR->GetArrayLength(ENVPAR buf);
- strs =(hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Awrite_float: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_float: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_float: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_float: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_float: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_FLOAT_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Awrite_float: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- if (strs == NULL) {
- h5JNIFatalError(env, "H5AwriteVL_asstr: failed to allocate buff for read variable length strings");
+ UNPIN_FLOAT_ARRAY(JNI_ABORT);
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1float */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_double
+ * Signature: (JJ[DZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1double
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jdouble *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Aread_double: buf is NULL");
} /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Aread_double: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_double: buf does not support variable length type");
+ } /* end else if */
else {
- status = H5Awrite(aid, tid, strs);
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Aread_double: H5Tdetect_variable_str() failed");
+ } /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Aread_double: buf does not support variable length type");
+ } /* end else if */
+ else {
+ PIN_DOUBLE_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Aread_double: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP);
- if (status < 0) {
- dims[0] = (hsize_t)n;
- sid = H5Screate_simple(1, dims, NULL);
- H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs);
- H5Sclose(sid);
- HDfree(strs);
- h5JNIFatalError(env, "H5AwriteVL_str: failed to read variable length strings");
+ if (status < 0) {
+ UNPIN_DOUBLE_ARRAY(JNI_ABORT);
+ h5libraryError(env);
+ } /* end if */
+ else {
+ UNPIN_DOUBLE_ARRAY(0);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1double */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_double
+ * Signature: (JJ[DZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1double
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning)
+{
+ herr_t status = -1;
+ jdouble *buffP;
+ jboolean isCopy;
+ htri_t data_class;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5Awrite_double: buf is NULL");
+ } /* end if */
+ else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_double: H5Tdetect_class() failed");
+ } /* end else if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_double: buf does not support variable length type");
+ } /* end else if */
+ else {
+ /* recursive detect any vlen string in type (compound, array ...) */
+ if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
+ h5JNIFatalError(env, "H5Awrite_double: H5Tdetect_variable_str() failed");
} /* end if */
+ else if(data_class == 1) {
+ h5badArgument(env, "H5Awrite_double: buf does not support variable length type");
+ } /* end else if */
else {
- for (i=0; i < n; i++) {
- jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]);
- ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
- H5free_memory (strs[i]);
+ PIN_DOUBLE_ARRAY();
+ if (buffP == NULL) {
+ h5JNIFatalError(env, "H5Awrite_double: buf not pinned");
+ } /* end if */
+ else {
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP);
+
+ UNPIN_DOUBLE_ARRAY(JNI_ABORT);
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1double */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_string
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1string
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf)
+{
+ herr_t status = -1;
+ char *c_buf;
+ char *cstr;
+ size_t str_len;
+ jsize i;
+ jsize n;
+ size_t pos;
+ jstring jstr;
+
+ c_buf = cstr = NULL;
+ if (j_buf == NULL) {
+ h5nullArgument(env, "H5Aread_string: buf is NULL");
+ } /* end if */
+ else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) {
+ h5nullArgument(env, "H5Aread_string: buf length <= 0");
+ } /* end else if */
+ else if ((str_len = H5Tget_size((hid_t)mem_type_id)) <=0) {
+ h5libraryError(env);
+ } /* end else if */
+ else {
+ if ((cstr = (char*)HDmalloc(str_len + 1)) == NULL) {
+ h5JNIFatalError(env, "H5Aread_string: memory allocation failed.");
+ } /* end if */
+ else {
+ if ((c_buf = (char*)HDmalloc((size_t)n * str_len)) == NULL) {
+ if (cstr)
+ HDfree(cstr);
+ cstr = NULL;
+ h5JNIFatalError(env, "H5Aread_string: memory allocation failed.");
+ } /* end if */
+ else {
+ status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf);
+
+ if (status < 0) {
+ if (cstr)
+ HDfree(cstr);
+ cstr = NULL;
+ if (c_buf)
+ HDfree(c_buf);
+ c_buf = NULL;
+ h5libraryError(env);
+ } /* end if */
+ else {
+ pos = 0;
+ for (i = 0; i < n; i++) {
+ HDmemcpy(cstr, c_buf+pos, str_len);
+ cstr[str_len] = '\0';
+ jstr = ENVPTR->NewStringUTF(ENVPAR cstr);
+ ENVPTR->SetObjectArrayElement(ENVPAR j_buf, i, jstr);
+ pos += str_len;
+ } /* end for */
+ } /* end else */
+
+ if (c_buf)
+ HDfree(c_buf);
+ } /* end else cbuf allocation*/
+
+ if (cstr)
+ HDfree(cstr);
+ } /* end else cstr allocation*/
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1string */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_string
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1string
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf)
+{
+ herr_t status = -1;
+ char *c_buf;
+ jsize str_len;
+ jsize i;
+ jsize n;
+
+ if (j_buf == NULL) {
+ h5nullArgument(env, "H5Awrite_string: buf is NULL");
+ } /* end if */
+ else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) {
+ h5nullArgument(env, "H5Awrite_string: buf length <= 0");
+ } /* end else if */
+ else if ((str_len = (jsize)H5Tget_size((hid_t)mem_type_id)) <=0) {
+ h5libraryError(env);
+ } /* end else if */
+ else {
+ if ((c_buf = (char*)HDmalloc((size_t)n * (size_t)str_len)) == NULL) {
+ h5JNIFatalError(env, "H5Awrite_string: memory allocation failed.");
+ } /* end if */
+ else {
+ for (i = 0; i < n; i++) {
+ jstring obj = (jstring)ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)j_buf, i);
+ if (obj != 0) {
+ jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
+ const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
+
+ if (utf8) {
+ HDstrncpy(&c_buf[i * str_len], utf8, str_len);
+ } /* end if */
+
+ ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
+ ENVPTR->DeleteLocalRef(ENVPAR obj);
+ } /* end if */
} /* end for */
- /*
- for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings,
- H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect
- free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings
- after it is done.
- H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs);
- */
+ status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, c_buf);
- HDfree(strs);
+ if (c_buf)
+ HDfree(c_buf);
+ c_buf = NULL;
+
+ if (status < 0) {
+ h5libraryError(env);
+ } /* end if */
} /* end else */
} /* end else */
- return status;
-} /* end H5AwriteVL_str */
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1string */
/*
* Class: hdf_hdf5lib_H5
* Method: H5AreadVL
- * Signature: (JJJJJ[Ljava/lang/String;)I
+ * Signature: (JJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5AreadVL
@@ -519,6 +1163,206 @@ H5AreadVL_str
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5AwriteVL
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5AwriteVL
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf)
+{
+ herr_t status = -1;
+ htri_t isStr = 0;
+ htri_t isVlenStr = 0;
+ htri_t isComplex = 0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5AwriteVL: buf is NULL");
+ } /* end if */
+ else {
+ isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+ if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
+ unsigned i;
+ int nm = H5Tget_nmembers(mem_type_id);
+ for(i = 0; i <nm; i++) {
+ hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
+ isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
+ H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
+ H5Tclose(nested_tid);
+ }
+ }
+ else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
+ isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
+ }
+ if (isStr == 0 || isComplex>0 || isVlenStr) {
+ status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
+ }
+ else if (isStr > 0) {
+ status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
+ }
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */
+
+herr_t
+H5AwriteVL_str
+ (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+{
+ herr_t status = -1;
+ char **wdata;
+ jsize size;
+ jint i;
+
+ size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf);
+
+ wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*));
+ if (!wdata) {
+ h5JNIFatalError(env, "H5AwriteVL_str: cannot allocate buffer");
+ } /* end if */
+ else {
+ HDmemset(wdata, 0, (size_t)size * sizeof(char*));
+ for (i = 0; i < size; ++i) {
+ jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i);
+ if (obj != 0) {
+ jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
+ const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
+
+ if (utf8) {
+ wdata[i] = (char*)HDmalloc((size_t)length + 1);
+ if (wdata[i]) {
+ HDmemset(wdata[i], 0, ((size_t)length + 1));
+ HDstrncpy(wdata[i], utf8, (size_t)length);
+ } /* end if */
+ } /* end if */
+
+ ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
+ ENVPTR->DeleteLocalRef(ENVPAR obj);
+ } /* end if */
+ } /* end for (i = 0; i < size; ++i) */
+
+ status = H5Awrite((hid_t)aid, (hid_t)tid, wdata);
+
+ for (i = 0; i < size; i++) {
+ if(wdata[i]) {
+ HDfree(wdata[i]);
+ } /* end if */
+ } /* end for */
+ HDfree(wdata);
+
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+
+ return (jint)status;
+}
+
+herr_t
+H5AwriteVL_asstr
+ (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+{
+ char **strs;
+ jstring jstr;
+ jint i;
+ jint n;
+ hid_t sid;
+ hsize_t dims[H5S_MAX_RANK];
+ herr_t status = -1;
+
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ strs =(hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+
+ if (strs == NULL) {
+ h5JNIFatalError(env, "H5AwriteVL_asstr: failed to allocate buff for read variable length strings");
+ } /* end if */
+ else {
+ status = H5Awrite(aid, tid, strs);
+
+ if (status < 0) {
+ dims[0] = (hsize_t)n;
+ sid = H5Screate_simple(1, dims, NULL);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs);
+ H5Sclose(sid);
+ HDfree(strs);
+ h5JNIFatalError(env, "H5AwriteVL_str: failed to read variable length strings");
+ } /* end if */
+ else {
+ for (i=0; i < n; i++) {
+ jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]);
+ ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
+ H5free_memory (strs[i]);
+ } /* end for */
+
+ /*
+ for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings,
+ H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect
+ free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings
+ after it is done.
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs);
+ */
+
+ HDfree(strs);
+ } /* end else */
+ } /* end else */
+
+ return status;
+} /* end H5AwriteVL_str */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_reg_ref
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref
+ (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf)
+{
+ herr_t status = -1;
+ h5str_t h5str;
+ size_t size;
+ hdset_reg_ref_t *ref_data;
+ jint i;
+ jint n;
+ jstring jstr;
+
+ hid_t region = -1;
+ hid_t aid = (hid_t) attr_id;
+ hid_t tid = (hid_t) mem_type_id;
+
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/
+ ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n);
+
+ if (ref_data == NULL) {
+ h5JNIFatalError(env, "H5Aread_reg_ref: failed to allocate buff for read");
+ return -1;
+ } /* end if */
+
+ status = H5Aread(aid, tid, ref_data);
+
+ if (status < 0) {
+ HDfree(ref_data);
+ h5JNIFatalError(env, "H5Aread_reg_ref: failed to read data");
+ return -1;
+ } /* end if */
+
+ HDmemset(&h5str, 0, sizeof(h5str_t));
+ h5str_new(&h5str, 1024);
+ for (i=0; i<n; i++) {
+ h5str.s[0] = '\0';
+ h5str_sprintf(&h5str, aid, tid, ref_data[i], 0, 0);
+ jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
+
+ ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
+ } /* end for */
+
+ h5str_free(&h5str);
+ HDfree(ref_data);
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Aget_space
* Signature: (J)J
*/
diff --git a/java/src/jni/h5aImp.h b/java/src/jni/h5aImp.h
index f3758eb..15cc83e 100644
--- a/java/src/jni/h5aImp.h
+++ b/java/src/jni/h5aImp.h
@@ -51,21 +51,120 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1idx
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Aread
+ * Signature: (JJ[B)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread
+ (JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Awrite
* Signature: (JJ[B)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Awrite
- (JNIEnv *, jclass, jlong, jlong, jbyteArray);
+ (JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean);
/*
* Class: hdf_hdf5lib_H5
- * Method: H5Aread
- * Signature: (JJ[B)I
+ * Method: H5Aread_short
+ * Signature: (JJ[SZ)I
*/
JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5Aread
- (JNIEnv *, jclass, jlong, jlong, jbyteArray);
+Java_hdf_hdf5lib_H5_H5Aread_1short
+ (JNIEnv*, jclass, jlong, jlong, jshortArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_short
+ * Signature: (JJ[SZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1short
+ (JNIEnv*, jclass, jlong, jlong, jshortArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_int
+ * Signature: (JJ[IZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1int
+ (JNIEnv*, jclass, jlong, jlong, jintArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_int
+ * Signature: (JJ[IZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1int
+ (JNIEnv*, jclass, jlong, jlong, jintArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_long
+ * Signature: (JJ[JZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1long
+ (JNIEnv*, jclass, jlong, jlong, jlongArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_long
+ * Signature: (JJ[JZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1long
+ (JNIEnv*, jclass, jlong, jlong, jlongArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_float
+ * Signature: (JJ[FZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1float
+ (JNIEnv*, jclass, jlong, jlong, jfloatArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_float
+ * Signature: (JJ[FZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1float
+ (JNIEnv*, jclass, jlong, jlong, jfloatArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_double
+ * Signature: (JJ[DZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1double
+ (JNIEnv*, jclass, jlong, jlong, jdoubleArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_double
+ * Signature: (JJ[DZ)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1double
+ (JNIEnv*, jclass, jlong, jlong, jdoubleArray, jboolean);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5AreadVL
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5AreadVL
+ (JNIEnv *, jclass, jlong, jlong, jobjectArray);
/*
* Class: hdf_hdf5lib_H5
@@ -78,12 +177,48 @@ Java_hdf_hdf5lib_H5_H5AwriteVL
/*
* Class: hdf_hdf5lib_H5
- * Method: H5AreadVL
+ * Method: H5Aread_string
* Signature: (JJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5AreadVL
- (JNIEnv *, jclass, jlong, jlong, jobjectArray);
+Java_hdf_hdf5lib_H5_H5Aread_1string
+ (JNIEnv*, jclass, jlong, jlong, jobjectArray);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_string
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1string
+(JNIEnv*, jclass, jlong, jlong, jobjectArray);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_VLStrings
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1VLStrings
+(JNIEnv*, jclass, jlong, jlong, jobjectArray);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Awrite_VLStrings
+ * Signature: (JJ[B)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings
+ (JNIEnv*, jclass, jlong, jlong, jobjectArray);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5Aread_reg_ref
+ * Signature: (JJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref
+(JNIEnv*, jclass, jlong, jlong, jobjectArray);
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c
index 652c873..79a5d0a 100644
--- a/java/src/jni/h5dImp.c
+++ b/java/src/jni/h5dImp.c
@@ -1574,84 +1574,6 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
/*
* Class: hdf_hdf5lib_H5
- * Method: H5Dread_reg_ref_data
- * Signature: (JJJJJ[Ljava/lang/String;)I
- */
-JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data
- (JNIEnv *env, jclass clss,
- jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
- jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
-{
- herr_t status = -1;
- h5str_t h5str;
- size_t size;
- hdset_reg_ref_t *ref_data;
- jint i;
- jint n;
- jstring jstr;
-
- hid_t region_obj;
- H5S_sel_type region_type;
-
- hid_t region = -1;
- hid_t did = (hid_t) dataset_id;
- hid_t tid = (hid_t) mem_type_id;
- hid_t mem_sid = (hid_t) mem_space_id;
- hid_t file_sid = (hid_t) file_space_id;
-
- n = ENVPTR->GetArrayLength(ENVPAR buf);
- size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/
- ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n);
-
- if (ref_data == NULL) {
- h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to allocate buff for read");
- return -1;
- } /* end if */
-
- status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data);
-
- if (status < 0) {
- HDfree(ref_data);
- h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to read data");
- return -1;
- } /* end if */
-
- HDmemset(&h5str, 0, sizeof(h5str_t));
- h5str_new(&h5str, 1024);
- for (i=0; i<n; i++) {
- h5str.s[0] = '\0';
-
- /* get name of the dataset the region reference points to using H5Rget_name */
- region_obj = H5Rdereference2(did, H5P_DEFAULT, H5R_DATASET_REGION, ref_data[i]);
- if (region_obj >= 0) {
- region = H5Rget_region(did, H5R_DATASET_REGION, ref_data[i]);
- if (region >= 0) {
- region_type = H5Sget_select_type(region);
- if(region_type==H5S_SEL_POINTS) {
- h5str_dump_region_points_data(&h5str, region, region_obj);
- } /* end if */
- else {
- h5str_dump_region_blocks_data(&h5str, region, region_obj);
- } /* end else */
-
- H5Sclose(region);
- } /* end if */
- H5Dclose(region_obj);
- } /* end if */
- jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
-
- ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
- } /* end for */
-
- h5str_free(&h5str);
- HDfree(ref_data);
-
- return (jint)status;
-} /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data */
-
-/*
- * Class: hdf_hdf5lib_H5
* Method: _H5Dcreate2
* Signature: (JLjava/lang/String;JJJJJ)J
*/
diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h
index 1fe71a8..f824452 100644
--- a/java/src/jni/h5dImp.h
+++ b/java/src/jni/h5dImp.h
@@ -250,7 +250,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_VLStrings
- * Signature: (JJJJJ[BZ)I
+ * Signature: (JJJJJ[B)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings
@@ -267,15 +267,6 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
/*
* Class: hdf_hdf5lib_H5
- * Method: H5Dread_reg_ref_data
- * Signature: (JJJJJ[Ljava/lang/String;)I
- */
-JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data
- (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray);
-
-/*
- * Class: hdf_hdf5lib_H5
* Method: _H5Dcreate2
* Signature: (JLjava/lang/String;JJJJJ)J
*/
diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c
index 9d68290..248e654 100644
--- a/java/src/jni/h5fImp.c
+++ b/java/src/jni/h5fImp.c
@@ -168,6 +168,33 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Fis_accessible
+ * Signature: (Ljava/lang/String;J)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_hdf_hdf5lib_H5_H5Fis_1accessible
+ (JNIEnv *env, jclass clss, jstring name, jlong file_id)
+{
+ htri_t bval = JNI_FALSE;
+ const char *fileName;
+
+ PIN_JAVA_STRING(name, fileName);
+ if (fileName != NULL) {
+ bval = H5Fis_accessible(fileName, (hid_t)file_id);
+
+ UNPIN_JAVA_STRING(name, fileName);
+
+ if (bval > 0)
+ bval = JNI_TRUE;
+ else if (bval < 0)
+ h5libraryError(env);
+ }
+
+ return (jboolean)bval;
+} /* end Java_hdf_hdf5lib_H5_H5Fis_1accessible */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Fget_create_plist
* Signature: (J)J
*/
@@ -177,7 +204,7 @@ Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist
{
hid_t retVal = -1;
- retVal = H5Fget_create_plist((hid_t)file_id );
+ retVal = H5Fget_create_plist((hid_t)file_id);
if (retVal < 0)
h5libraryError(env);
diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h
index fcfdedf..af0fa1d 100644
--- a/java/src/jni/h5fImp.h
+++ b/java/src/jni/h5fImp.h
@@ -68,6 +68,15 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Fis_accessible
+ * Signature: (Ljava/lang/String;J)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_hdf_hdf5lib_H5_H5Fis_1ccessible
+ (JNIEnv*, jclass, jstring, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Fget_create_plist
* Signature: (J)J
*/
diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c
new file mode 100644
index 0000000..89ea703
--- /dev/null
+++ b/java/src/jni/h5vlImp.c
@@ -0,0 +1,206 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * For details of the HDF libraries, see the HDF Documentation at:
+ * http://hdfgroup.org/HDF5/doc/
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "hdf5.h"
+#include <jni.h>
+#include <stdlib.h>
+#include "h5jni.h"
+#include "h5vlImp.h"
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLregister_connector_by_name
+ * Signature: (Ljava/lang/String;J)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name
+ (JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id)
+{
+ hid_t status = -1;
+ const char *vlName;
+
+ PIN_JAVA_STRING(connector_name, vlName);
+ if (vlName != NULL) {
+ status = H5VLregister_connector_by_name(vlName, (hid_t)vipl_id);
+
+ UNPIN_JAVA_STRING(connector_name, vlName);
+
+ if (status < 0)
+ h5libraryError(env);
+ }
+
+ return (jlong)status;
+} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLregister_connector_by_value
+ * Signature: (IJ)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value
+ (JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id)
+{
+ hid_t status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id);
+
+ if (status < 0)
+ h5libraryError(env);
+
+ return (jlong)status;
+} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLis_connector_registered
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered
+ (JNIEnv *env, jclass clss, jobject connector_name)
+{
+ htri_t bval = JNI_FALSE;
+ const char *vlName;
+
+ PIN_JAVA_STRING(connector_name, vlName);
+ if (vlName != NULL) {
+ bval = H5VLis_connector_registered(vlName);
+
+ UNPIN_JAVA_STRING(connector_name, vlName);
+
+ if (bval > 0)
+ bval = JNI_TRUE;
+ else if (bval < 0)
+ h5libraryError(env);
+ }
+
+ return (jboolean)bval;
+} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLget_connector_id
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5VLget_1connector_1id
+ (JNIEnv *env, jclass clss, jobject connector_name)
+{
+ hid_t status = -1;
+ const char *vlName;
+
+ PIN_JAVA_STRING(connector_name, vlName);
+ if (vlName != NULL) {
+ status = H5VLget_connector_id(vlName);
+
+ UNPIN_JAVA_STRING(connector_name, vlName);
+
+ if (status < 0)
+ h5libraryError(env);
+ }
+
+ return (jlong)status;
+} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLget_connector_name
+ * Signature: (J)Ljava/lang/String;
+ */
+
+JNIEXPORT jobject JNICALL
+Java_hdf_hdf5lib_H5_H5VLget_1connector_1name
+ (JNIEnv *env, jclass clss, jlong object_id)
+{
+ char *vlName;
+ ssize_t buf_size;
+ ssize_t status;
+ jstring str = NULL;
+
+ /* get the length of the comment */
+ buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0);
+ if (buf_size < 0) {
+ H5Eprint2(H5E_DEFAULT, NULL);
+
+ h5badArgument(env, "H5VLget_connector_name: buf_size < 0");
+ } /* end if */
+ else if (buf_size > 0) {
+ buf_size++; /* add extra space for the null terminator */
+ vlName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size);
+ if (vlName == NULL) {
+ /* exception -- out of memory */
+ h5outOfMemory(env, "H5VLget_connector_name: malloc failed");
+ } /* end if */
+ else {
+ status = H5VLget_connector_name((hid_t)object_id, vlName, (size_t)buf_size);
+
+ if (status < 0) {
+ h5libraryError(env);
+ } /* end if */
+ else {
+ /* may throw OutOfMemoryError */
+ str = ENVPTR->NewStringUTF(ENVPAR vlName);
+ if (str == NULL) {
+ h5JNIFatalError(env, "H5VLget_connector_name: return string not allocated");
+ } /* end if */
+ } /* end else */
+ HDfree(vlName);
+ }
+ } /* end else if */
+
+ return (jstring)str;
+} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1name */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLclose
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL
+Java_hdf_hdf5lib_H5_H5VLclose
+ (JNIEnv *env, jclass clss, jlong connector_id)
+{
+ herr_t retValue = H5VLclose((hid_t)connector_id);
+
+ if (retValue < 0)
+ h5libraryError(env);
+} /* end Java_hdf_hdf5lib_H5_H5VLclose */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLunregister_connector
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL
+Java_hdf_hdf5lib_H5_H5VLunregister_1connector
+ (JNIEnv *env, jclass clss, jlong connector_id)
+{
+ herr_t retValue = H5VLunregister_connector((hid_t)connector_id);
+
+ if (retValue < 0)
+ h5libraryError(env);
+} /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */
+
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif /* __cplusplus */
diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h
new file mode 100644
index 0000000..af824a9
--- /dev/null
+++ b/java/src/jni/h5vlImp.h
@@ -0,0 +1,91 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include <jni.h>
+/* Header for class hdf_hdf5lib_H5_H5VL */
+
+#ifndef _Included_hdf_hdf5lib_H5_H5VL
+#define _Included_hdf_hdf5lib_H5_H5VL
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLregister_connector_by_name
+ * Signature: (Ljava/lang/String;J)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name
+ (JNIEnv *, jclass, jobject, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLregister_connector_by_value
+ * Signature: (IJ)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value
+ (JNIEnv *, jclass, jint, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLis_connector_registered
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_hdf_hdf5lib_H5_H5VLis_connector_registered
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLget_connector_id
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5VLget_1connector_1id
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLget_connector_name
+ * Signature: (J)Ljava/lang/String;
+ */
+
+JNIEXPORT jobject JNICALL
+Java_hdf_hdf5lib_H5_H5VLget_1connector_1name
+ (JNIEnv *, jclass, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLclose
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL
+Java_hdf_hdf5lib_H5_H5VLclose
+ (JNIEnv *, jclass, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5VLunregister_connector
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL
+Java_hdf_hdf5lib_H5_H5VLunregister_1connector
+ (JNIEnv *, jclass, jlong);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif /* __cplusplus */
+
+#endif /* _Included_hdf_hdf5lib_H5_H5VL */