summaryrefslogtreecommitdiffstats
path: root/java/src/jni/exceptionImp.c
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/jni/exceptionImp.c')
-rw-r--r--java/src/jni/exceptionImp.c135
1 files changed, 58 insertions, 77 deletions
diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c
index c08b67b..c5e7d85 100644
--- a/java/src/jni/exceptionImp.c
+++ b/java/src/jni/exceptionImp.c
@@ -21,7 +21,6 @@
extern "C" {
#endif /* __cplusplus */
-
/***********/
/* Headers */
/***********/
@@ -33,9 +32,8 @@ extern "C" {
#include "h5jni.h"
#include "exceptionImp.h"
-extern H5E_auto2_t efunc;
-extern void *edata;
-
+extern H5E_auto2_t efunc;
+extern void * edata;
/*******************/
/* Local Variables */
@@ -47,13 +45,13 @@ extern void *edata;
* minor error numbers.
*/
typedef struct H5E_major_mesg_t {
- hid_t error_code;
- const char *str;
+ hid_t error_code;
+ const char *str;
} H5E_major_mesg_t;
typedef struct H5E_minor_mesg_t {
- hid_t error_code;
- const char *str;
+ hid_t error_code;
+ const char *str;
} H5E_minor_mesg_t;
/* major and minor error numbers */
@@ -66,42 +64,41 @@ typedef struct H5E_num_t {
/* Local Macros */
/********************/
-#define THROWEXCEPTION(className, args) \
-{ \
- jmethodID jm; \
- jclass jc; \
- jobject ex; \
- \
- if (NULL == (jc = ENVPTR->FindClass(ENVONLY, (className)))) \
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
- \
- if (NULL == (jm = ENVPTR->GetMethodID(ENVONLY, jc, "<init>", "(Ljava/lang/String;)V"))) { \
- HDprintf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
- } \
- \
- if (NULL == (ex = ENVPTR->NewObjectA(ENVONLY, jc, jm, (jvalue *)(args)))) { \
- HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Creation failed\n", (className)); \
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
- } \
- \
- if (ENVPTR->Throw(ENVONLY, (jthrowable)ex) < 0) { \
- HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Throw failed\n", (className)); \
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
- } \
-}
+#define THROWEXCEPTION(className, args) \
+ { \
+ jmethodID jm; \
+ jclass jc; \
+ jobject ex; \
+ \
+ if (NULL == (jc = ENVPTR->FindClass(ENVONLY, (className)))) \
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
+ \
+ if (NULL == (jm = ENVPTR->GetMethodID(ENVONLY, jc, "<init>", "(Ljava/lang/String;)V"))) { \
+ HDprintf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
+ } \
+ \
+ if (NULL == (ex = ENVPTR->NewObjectA(ENVONLY, jc, jm, (jvalue *)(args)))) { \
+ HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Creation failed\n", (className)); \
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
+ } \
+ \
+ if (ENVPTR->Throw(ENVONLY, (jthrowable)ex) < 0) { \
+ HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Throw failed\n", (className)); \
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \
+ } \
+ }
/********************/
/* Local Prototypes */
/********************/
static const char *defineHDF5LibraryException(hid_t maj_num);
-static jboolean H5JNIErrorClass(JNIEnv *env, const char *message, const char *className);
+static jboolean H5JNIErrorClass(JNIEnv *env, const char *message, const char *className);
/* get the major and minor error numbers on the top of the error stack */
static herr_t
-walk_error_callback
- (unsigned n, const H5E_error2_t *err_desc, void *_err_nums)
+walk_error_callback(unsigned n, const H5E_error2_t *err_desc, void *_err_nums)
{
H5E_num_t *err_nums = (H5E_num_t *)_err_nums;
@@ -122,8 +119,7 @@ walk_error_callback
*
*/
JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5error_1off
- (JNIEnv *env, jclass clss)
+Java_hdf_hdf5lib_H5_H5error_1off(JNIEnv *env, jclass clss)
{
UNUSED(env);
UNUSED(clss);
@@ -144,8 +140,7 @@ Java_hdf_hdf5lib_H5_H5error_1off
*
*/
JNIEXPORT void JNICALL
-Java_hdf_hdf5lib_H5_H5error_1on
- (JNIEnv *env, jclass clss)
+Java_hdf_hdf5lib_H5_H5error_1on(JNIEnv *env, jclass clss)
{
UNUSED(env);
UNUSED(clss);
@@ -161,11 +156,10 @@ Java_hdf_hdf5lib_H5_H5error_1on
* Call the HDF-5 library to print the HDF-5 error stack to 'file_name'.
*/
JNIEXPORT void JNICALL
-Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0
- (JNIEnv *env, jobject obj, jstring file_name)
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0(JNIEnv *env, jobject obj, jstring file_name)
{
- FILE *stream = NULL;
- const char *file = NULL;
+ FILE * stream = NULL;
+ const char *file = NULL;
UNUSED(obj);
@@ -196,8 +190,7 @@ done:
* Extract the HDF-5 major error number from the HDF-5 error stack.
*/
JNIEXPORT jlong JNICALL
-Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber
- (JNIEnv *env, jobject obj)
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber(JNIEnv *env, jobject obj)
{
H5E_num_t err_nums;
@@ -221,8 +214,7 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber
* Extract the HDF-5 minor error number from the HDF-5 error stack.
*/
JNIEXPORT jlong JNICALL
-Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber
- (JNIEnv *env, jobject obj)
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber(JNIEnv *env, jobject obj)
{
H5E_num_t err_nums;
@@ -242,17 +234,16 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber
* Routine to raise particular Java exceptions from C.
*/
static jboolean
-H5JNIErrorClass
- (JNIEnv *env, const char *message, const char *className)
+H5JNIErrorClass(JNIEnv *env, const char *message, const char *className)
{
- jstring str;
- char *args[2];
- jboolean retVal = JNI_FALSE;
+ jstring str;
+ char * args[2];
+ jboolean retVal = JNI_FALSE;
if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, message)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
- args[0] = (char *) str;
+ args[0] = (char *)str;
args[1] = 0;
THROWEXCEPTION(className, args);
@@ -271,13 +262,11 @@ done:
* exception.
*/
jboolean
-h5outOfMemory
- (JNIEnv *env, const char *functName)
+h5outOfMemory(JNIEnv *env, const char *functName)
{
return H5JNIErrorClass(env, functName, "java/lang/OutOfMemoryError");
} /* end h5outOfMemory() */
-
/*
* A fatal error in a JNI call
* Create and throw an 'InternalError'
@@ -287,8 +276,7 @@ h5outOfMemory
* exception.
*/
jboolean
-h5JNIFatalError
- (JNIEnv *env, const char *functName)
+h5JNIFatalError(JNIEnv *env, const char *functName)
{
return H5JNIErrorClass(env, functName, "java/lang/InternalError");
} /* end h5JNIFatalError() */
@@ -302,8 +290,7 @@ h5JNIFatalError
* exception.
*/
jboolean
-h5nullArgument
- (JNIEnv *env, const char *functName)
+h5nullArgument(JNIEnv *env, const char *functName)
{
return H5JNIErrorClass(env, functName, "java/lang/NullPointerException");
} /* end h5nullArgument() */
@@ -317,8 +304,7 @@ h5nullArgument
* exception.
*/
jboolean
-h5badArgument
- (JNIEnv *env, const char *functName)
+h5badArgument(JNIEnv *env, const char *functName)
{
return H5JNIErrorClass(env, functName, "java/lang/IllegalArgumentException");
} /* end h5badArgument() */
@@ -332,8 +318,7 @@ h5badArgument
* exception.
*/
jboolean
-h5unimplemented
- (JNIEnv *env, const char *functName)
+h5unimplemented(JNIEnv *env, const char *functName)
{
return H5JNIErrorClass(env, functName, "java/lang/UnsupportedOperationException");
} /* end h5unimplemented() */
@@ -346,8 +331,7 @@ h5unimplemented
* exception.
*/
jboolean
-h5raiseException
- (JNIEnv *env, const char *message, const char *exception)
+h5raiseException(JNIEnv *env, const char *message, const char *exception)
{
return H5JNIErrorClass(env, message, exception);
} /* end h5raiseException() */
@@ -364,20 +348,19 @@ h5raiseException
* exception.
*/
jboolean
-h5libraryError
- (JNIEnv *env)
+h5libraryError(JNIEnv *env)
{
const char *exception = NULL;
H5E_type_t error_msg_type;
H5E_num_t exceptionNumbers;
- jstring str = NULL;
+ jstring str = NULL;
ssize_t msg_size = 0;
hid_t min_num;
hid_t maj_num;
hid_t stk_id = H5I_INVALID_HID;
- char *args[2];
- char *msg_str = NULL;
- jboolean retVal = JNI_FALSE;
+ char * args[2];
+ char * msg_str = NULL;
+ jboolean retVal = JNI_FALSE;
exceptionNumbers.maj_num = 0;
exceptionNumbers.min_num = 0;
@@ -408,7 +391,7 @@ h5libraryError
goto done;
if (msg_size > 0) {
- if (NULL == (msg_str = (char *) HDcalloc((size_t)msg_size + 1, sizeof(char))))
+ if (NULL == (msg_str = (char *)HDcalloc((size_t)msg_size + 1, sizeof(char))))
H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5libraryerror: failed to allocate buffer for error message");
if ((msg_size = H5Eget_msg(min_num, &error_msg_type, msg_str, (size_t)msg_size + 1)) < 0)
@@ -424,7 +407,7 @@ h5libraryError
if (stk_id >= 0)
H5Eset_current_stack(stk_id);
- args[0] = (char *) str;
+ args[0] = (char *)str;
args[1] = 0;
THROWEXCEPTION(exception, args);
@@ -443,8 +426,7 @@ done:
* which goes with an HDF-5 error code.
*/
static const char *
-defineHDF5LibraryException
- (hid_t maj_num)
+defineHDF5LibraryException(hid_t maj_num)
{
hid_t err_num = maj_num;
@@ -497,4 +479,3 @@ defineHDF5LibraryException
#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */
-