From b5867a05a7adf5d1c89721bf42a5bbaddb47dbd9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 13 Mar 2018 17:21:02 -0500 Subject: HDFFV-10412 add error on function for Java --- java/src/hdf/hdf5lib/H5.java | 8 +++++++- java/src/jni/exceptionImp.c | 17 +++++++++++++++++ java/src/jni/exceptionImp.h | 10 ++++++++++ java/src/jni/h5util.c | 3 +++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 20aa634..9d1aed1 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -424,7 +424,7 @@ public class H5 implements java.io.Serializable { private synchronized static native int H5dont_atexit() throws HDF5LibraryException; /** - * Turn off error handling By default, the C library prints the error stack of the HDF-5 C library on stdout. This + * Turn off error handling. By default, the C library prints the error stack of the HDF-5 C library on stdout. This * behavior may be disabled by calling H5error_off(). * * @return a non-negative value if successful @@ -432,6 +432,12 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5error_off(); /** + * Turn on error handling. By default, the C library prints the error stack of the HDF-5 C library on stdout. This + * behavior may be reenabled by calling H5error_on(). + */ + public synchronized static native void H5error_on(); + + /** * H5garbage_collect collects on all free-lists of all types. * * @return a non-negative value if successful diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c index 05c193f..afad5d5 100644 --- a/java/src/jni/exceptionImp.c +++ b/java/src/jni/exceptionImp.c @@ -33,6 +33,9 @@ extern "C" { #include "h5jni.h" #include "exceptionImp.h" +extern H5E_auto2_t efunc; +extern void *edata; + /*******************/ /* Local Variables */ @@ -122,10 +125,24 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5error_1off (JNIEnv *env, jclass clss) { + H5Eget_auto2(H5E_DEFAULT, &efunc, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); return 0; } /* end Java_hdf_hdf5lib_H5_H5error_1off() */ +/* + * Class: hdf_hdf5lib_exceptions_HDF5Library + * Method: H5error_on + * Signature: ()V + * + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5error_1on + (JNIEnv *env, jclass clss) +{ + H5Eset_auto2(H5E_DEFAULT, efunc, edata); +} /* end Java_hdf_hdf5lib_H5_H5error_1on() */ + /* * Class: hdf_hdf5lib_exceptions_HDFLibraryException diff --git a/java/src/jni/exceptionImp.h b/java/src/jni/exceptionImp.h index cb74602..423e537 100644 --- a/java/src/jni/exceptionImp.h +++ b/java/src/jni/exceptionImp.h @@ -31,6 +31,16 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5error_1off (JNIEnv *env, jclass clss ); +/* + * Class: hdf_hdf5lib_exceptions_HDF5Library + * Method: H5error_on + * Signature: ()V + * + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5error_1on + (JNIEnv *env, jclass clss ); + /* * Class: hdf_hdf5lib_exceptions_HDFLibraryException diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index bd9fc0f..fdabd76 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -41,6 +41,9 @@ jobject get_callback; jobject set_callback; jobject delete_callback; +H5E_auto2_t efunc; +void *edata; + /********************/ /* Local Prototypes */ /********************/ -- cgit v0.12