diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/src/jni/exceptionImp.c | 33 | ||||
-rw-r--r-- | java/src/jni/h5jni.h | 21 | ||||
-rw-r--r-- | java/src/jni/h5util.c | 70 | ||||
-rw-r--r-- | java/test/TestAll.java | 3 | ||||
-rw-r--r-- | java/test/TestH5Rref.java | 3 |
5 files changed, 74 insertions, 56 deletions
diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c index e62caee..12ef0a1 100644 --- a/java/src/jni/exceptionImp.c +++ b/java/src/jni/exceptionImp.c @@ -262,12 +262,25 @@ done: * exception. */ jboolean -h5outOfMemory(JNIEnv *env, const char *functName) +h5outOfMemory(JNIEnv *env, const char *message) { - return H5JNIErrorClass(env, functName, "java/lang/OutOfMemoryError"); + return H5JNIErrorClass(env, message, "java/lang/OutOfMemoryError"); } /* end h5outOfMemory() */ /* + * Create and throw an 'AssertionError' + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5assertion(JNIEnv *env, const char *message) +{ + return H5JNIErrorClass(env, message, "java/lang/AssertionError"); +} /* end h5assertion() */ + +/* * A fatal error in a JNI call * Create and throw an 'InternalError' * @@ -276,9 +289,9 @@ h5outOfMemory(JNIEnv *env, const char *functName) * exception. */ jboolean -h5JNIFatalError(JNIEnv *env, const char *functName) +h5JNIFatalError(JNIEnv *env, const char *message) { - return H5JNIErrorClass(env, functName, "java/lang/InternalError"); + return H5JNIErrorClass(env, message, "java/lang/InternalError"); } /* end h5JNIFatalError() */ /* @@ -290,9 +303,9 @@ h5JNIFatalError(JNIEnv *env, const char *functName) * exception. */ jboolean -h5nullArgument(JNIEnv *env, const char *functName) +h5nullArgument(JNIEnv *env, const char *message) { - return H5JNIErrorClass(env, functName, "java/lang/NullPointerException"); + return H5JNIErrorClass(env, message, "java/lang/NullPointerException"); } /* end h5nullArgument() */ /* @@ -304,9 +317,9 @@ h5nullArgument(JNIEnv *env, const char *functName) * exception. */ jboolean -h5badArgument(JNIEnv *env, const char *functName) +h5badArgument(JNIEnv *env, const char *message) { - return H5JNIErrorClass(env, functName, "java/lang/IllegalArgumentException"); + return H5JNIErrorClass(env, message, "java/lang/IllegalArgumentException"); } /* end h5badArgument() */ /* @@ -318,9 +331,9 @@ h5badArgument(JNIEnv *env, const char *functName) * exception. */ jboolean -h5unimplemented(JNIEnv *env, const char *functName) +h5unimplemented(JNIEnv *env, const char *message) { - return H5JNIErrorClass(env, functName, "java/lang/UnsupportedOperationException"); + return H5JNIErrorClass(env, message, "java/lang/UnsupportedOperationException"); } /* end h5unimplemented() */ /* h5raiseException(). This routine is called to generate diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h index aab5479..2ec30da 100644 --- a/java/src/jni/h5jni.h +++ b/java/src/jni/h5jni.h @@ -266,9 +266,10 @@ extern jboolean h5JNIFatalError(JNIEnv *env, const char *); extern jboolean h5nullArgument(JNIEnv *env, const char *); extern jboolean h5badArgument(JNIEnv *env, const char *); extern jboolean h5outOfMemory(JNIEnv *env, const char *); +extern jboolean h5assertion(JNIEnv *env, const char *); +extern jboolean h5unimplemented(JNIEnv *env, const char *); extern jboolean h5libraryError(JNIEnv *env); extern jboolean h5raiseException(JNIEnv *env, const char *, const char *); -extern jboolean h5unimplemented(JNIEnv *env, const char *functName); /* * The following macros are to facilitate immediate cleanup+return @@ -304,21 +305,27 @@ extern jboolean h5unimplemented(JNIEnv *env, const char *functName); goto done; \ } while (0) -#define H5_LIBRARY_ERROR(env) \ +#define H5_ASSERTION_ERROR(env, message) \ do { \ - h5libraryError(env); \ + h5assertion(env, message); \ goto done; \ } while (0) -#define H5_RAISE_EXCEPTION(env, message, exception) \ +#define H5_UNIMPLEMENTED(env, message) \ do { \ - h5raiseException(env, message, exception); \ + h5unimplemented(env, message); \ goto done; \ } while (0) -#define H5_UNIMPLEMENTED(env, message) \ +#define H5_LIBRARY_ERROR(env) \ do { \ - h5unimplemented(env, message); \ + h5libraryError(env); \ + goto done; \ + } while (0) + +#define H5_RAISE_EXCEPTION(env, message, exception) \ + do { \ + h5raiseException(env, message, exception); \ goto done; \ } while (0) diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 3e1962e..2e02e4d 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -657,14 +657,14 @@ h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, void *ref_p) int ret_value = FAIL; if (!h5str_append(out_str, " \"")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); buf_size = H5Rget_file_name(ref_vp, NULL, 0); if (buf_size) { ref_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1); if (H5Rget_file_name(ref_vp, ref_name, buf_size + 1) >= 0) { ref_name[buf_size] = '\0'; if (!h5str_append(out_str, ref_name)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } HDfree(ref_name); ref_name = NULL; @@ -676,7 +676,7 @@ h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, void *ref_p) if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, ref_name, buf_size + 1) >= 0) { ref_name[buf_size] = '\0'; if (!h5str_append(out_str, ref_name)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } HDfree(ref_name); ref_name = NULL; @@ -689,14 +689,14 @@ h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, void *ref_p) if (H5Rget_attr_name(ref_vp, ref_name, buf_size + 1) >= 0) { ref_name[buf_size] = '\0'; if (!h5str_append(out_str, ref_name)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } HDfree(ref_name); ref_name = NULL; } } if (!h5str_append(out_str, "\"")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); ret_value = SUCCEED; done: @@ -1044,7 +1044,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i H5_LIBRARY_ERROR(ENVONLY); if (!h5str_append(out_str, H5_COMPOUND_BEGIN_INDICATOR)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); for (i = 0; i < (unsigned)n; i++) { offset = H5Tget_member_offset(tid, i); @@ -1057,7 +1057,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if ((i + 1) < (unsigned)n) if (!h5str_append(out_str, ", ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); if (H5Tclose(mtid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1065,7 +1065,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i } if (!h5str_append(out_str, H5_COMPOUND_END_INDICATOR)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); break; } @@ -1075,7 +1075,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) { if (!h5str_append(out_str, enum_name)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } else { size_t i; @@ -1140,7 +1140,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if (HDsprintf(this_str, "%u-", (unsigned)oi.type) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); if (!h5str_append(out_str, this_str)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); HDfree(this_str); this_str = NULL; @@ -1190,7 +1190,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i } /* end switch */ } else - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: H5R_OBJECT2 failed"); + H5_ASSERTION_ERROR(ENVONLY, "h5str_sprintf: H5R_OBJECT2 failed"); break; case H5R_DATASET_REGION2: if (h5str_region_dataset(ENVONLY, out_str, ref_vp, expand_data) < 0) @@ -1231,7 +1231,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i int rank = 0; if (!h5str_append(out_str, H5_ARRAY_BEGIN_INDICATOR)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); if ((mtid = H5Tget_super(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1254,11 +1254,11 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if ((i + 1) < total_elmts) if (!h5str_append(out_str, ", ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } if (!h5str_append(out_str, H5_ARRAY_END_INDICATOR)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); if (H5Tclose(mtid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1279,7 +1279,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i H5_LIBRARY_ERROR(ENVONLY); if (!h5str_append(out_str, H5_VLEN_BEGIN_INDICATOR)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); for (i = 0; i < (unsigned)vl_buf->len; i++) { if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(((char *)vl_buf->p)[i * baseSize]), @@ -1288,11 +1288,11 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if ((i + 1) < (unsigned)vl_buf->len) if (!h5str_append(out_str, ", ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } if (!h5str_append(out_str, H5_VLEN_END_INDICATOR)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); if (H5Tclose(mtid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1334,7 +1334,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if (this_str) { if (!h5str_append(out_str, this_str)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); HDfree(this_str); this_str = NULL; @@ -1440,7 +1440,7 @@ h5str_print_region_data_blocks(JNIEnv *env, hid_t region_id, h5str_t *str, int n if (numindex + 1 < numelem) if (!h5str_append(str, ", ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ @@ -1509,16 +1509,16 @@ h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re } else { if (!h5str_append(str, " REGION_TYPE BLOCK")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); if (!h5str_append(str, " {")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); for (i = 0; i < nblocks; i++) { int j; if (!h5str_append(str, " ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); /* Start coordinates and opposite corner */ for (j = 0; j < ndims; j++) { @@ -1528,7 +1528,7 @@ h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); if (!h5str_append(str, tmp_str)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } for (j = 0; j < ndims; j++) { @@ -1539,17 +1539,17 @@ h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); if (!h5str_append(str, tmp_str)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } if (!h5str_append(str, ") ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); tmp_str[0] = '\0'; } if (!h5str_append(str, " }")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } ret_value = SUCCEED; @@ -1620,7 +1620,7 @@ h5str_print_region_data_points(JNIEnv *env, hid_t region_space, hid_t region_id, if (jndx + 1 < (size_t)npoints) if (!h5str_append(str, ", ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */ ret_value = SUCCEED; @@ -1684,16 +1684,16 @@ h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re } else { if (!h5str_append(str, " REGION_TYPE POINT")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); if (!h5str_append(str, " {")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); for (i = 0; i < npoints; i++) { int j; if (!h5str_append(str, " ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; @@ -1702,15 +1702,15 @@ h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: HDsprintf failure"); if (!h5str_append(str, tmp_str)) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } /* end for (j = 0; j < ndims; j++) */ if (!h5str_append(str, ") ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } /* end for (i = 0; i < npoints; i++) */ if (!h5str_append(str, " }")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } ret_value = SUCCEED; @@ -2719,7 +2719,7 @@ h5str_dump_region_attribute(JNIEnv *env, h5str_t *str, hid_t region_id) if ((i < p_nelmts - 1) && (bytes_in > 0)) { if (!h5str_append(str, ", ")) - H5_LIBRARY_ERROR(ENVONLY); + H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); } } @@ -3620,7 +3620,7 @@ Java_hdf_hdf5lib_H5_H5export_1dataset(JNIEnv *env, jclass clss, jstring file_exp H5_JNI_FATAL_ERROR(ENVONLY, "HDfopen failed"); if ((ret_val = h5str_dump_simple_dset(ENVONLY, stream, dataset_id, binary_order)) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_simple_dset failed"); + H5_ASSERTION_ERROR(ENVONLY, "h5str_dump_simple_dset failed"); if (stream) { HDfclose(stream); diff --git a/java/test/TestAll.java b/java/test/TestAll.java index a59e990..3950072 100644 --- a/java/test/TestAll.java +++ b/java/test/TestAll.java @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,7 +24,7 @@ import org.junit.runners.Suite; TestH5Tparams.class, TestH5Tbasic.class, TestH5T.class, TestH5Dparams.class, TestH5D.class, TestH5Dplist.class, TestH5Lparams.class, TestH5Lbasic.class, TestH5Lcreate.class, - TestH5R.class, + TestH5R.class, TestH5Rref.class, TestH5P.class, TestH5PData.class, TestH5Pfapl.class, TestH5Pvirtual.class, TestH5Plist.class, TestH5Pfapls3.class, TestH5Pfaplhdfs.class, TestH5A.class, diff --git a/java/test/TestH5Rref.java b/java/test/TestH5Rref.java index e306d7a..aeec64f 100644 --- a/java/test/TestH5Rref.java +++ b/java/test/TestH5Rref.java @@ -1,12 +1,11 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |