diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/src/hdf/hdf5lib/H5.java | 26 | ||||
-rw-r--r-- | java/src/jni/h5aImp.c | 29 | ||||
-rw-r--r-- | java/src/jni/h5dImp.c | 22 | ||||
-rw-r--r-- | java/src/jni/h5fImp.c | 9 | ||||
-rw-r--r-- | java/src/jni/h5tImp.c | 31 | ||||
-rw-r--r-- | java/src/jni/h5tImp.h | 9 | ||||
-rw-r--r-- | java/src/jni/h5util.c | 2 | ||||
-rw-r--r-- | java/test/TestH5Dparams.java | 11 | ||||
-rw-r--r-- | java/test/TestH5Tparams.java | 11 | ||||
-rw-r--r-- | java/test/testfiles/JUnit-TestH5Dparams.txt | 4 | ||||
-rw-r--r-- | java/test/testfiles/JUnit-TestH5Tparams.txt | 4 |
11 files changed, 131 insertions, 27 deletions
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index adb50f1..09fb223 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -2155,7 +2155,10 @@ public class H5 implements java.io.Serializable { * - Error from the HDF-5 Library. * @exception NullPointerException * - buf is null. + * + * @deprecated As of HDF5 1.12.0 in favor of H5Treclaim **/ + @Deprecated public synchronized static native int H5Dvlen_reclaim(long type_id, long space_id, long xfer_plist_id, byte[] buf) throws HDF5LibraryException, NullPointerException; @@ -3093,6 +3096,7 @@ public class H5 implements java.io.Serializable { * * @deprecated As of HDF5 1.10.5 in favor of H5Fis_accessible. **/ + @Deprecated public synchronized static native boolean H5Fis_hdf5(String name) throws HDF5LibraryException, NullPointerException; /** @@ -10313,6 +10317,28 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Tpack(long type_id) throws HDF5LibraryException; /** + * H5Treclaim reclaims buffer used for VL data. + * + * @param type_id + * Identifier of the datatype. + * @param space_id + * Identifier of the dataspace. + * @param xfer_plist_id + * Identifier of a transfer property list for this I/O operation. + * @param buf + * Buffer with data to be reclaimed. + * + * @return a non-negative value if successful + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - buf is null. + **/ + public synchronized static native int H5Treclaim(long type_id, long space_id, long xfer_plist_id, byte[] buf) + throws HDF5LibraryException, NullPointerException; + + /** * H5Tvlen_create creates a new variable-length (VL) dataype. * * @param base_id diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index eaa356e..9f22665 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -94,11 +94,18 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name) { +#ifndef H5_NO_DEPRECATED_SYMBOLS const char *attrName = NULL; +#endif hid_t attr_id = H5I_INVALID_HID; UNUSED(clss); +#ifdef H5_NO_DEPRECATED_SYMBOLS + UNUSED(loc_id); + UNUSED(name); + H5_UNIMPLEMENTED(ENVONLY, "H5Aopen_name: not implemented"); +#else if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aopen_name: attribute name is null"); @@ -106,10 +113,13 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1name if((attr_id = H5Aopen_name((hid_t)loc_id, attrName)) < 0) H5_LIBRARY_ERROR(ENVONLY); +#endif done: +#ifndef H5_NO_DEPRECATED_SYMBOLS if (attrName) UNPIN_JAVA_STRING(ENVONLY, name, attrName); +#endif return (jlong)attr_id; } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1name */ @@ -127,8 +137,14 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1idx UNUSED(clss); +#ifdef H5_NO_DEPRECATED_SYMBOLS + UNUSED(loc_id); + UNUSED(idx); + H5_UNIMPLEMENTED(ENVONLY, "H5Aopen_idx: not implemented"); +#else if ((attr_id = H5Aopen_idx((hid_t) loc_id, (unsigned int) idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); +#endif done: return (jlong)attr_id; @@ -1028,7 +1044,7 @@ H5AreadVL_str /* * When 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 + * H5Treclaim() may crash on Windows because the Java GC will not be able to collect * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings * once done. */ @@ -1125,7 +1141,7 @@ done: if (h5str.s) h5str_free(&h5str); if (readBuf) { - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, readBuf); + H5Treclaim(tid, sid, H5P_DEFAULT, readBuf); HDfree(readBuf); } if (sid >= 0) @@ -1313,7 +1329,7 @@ H5AwriteVL_asstr /* * When repeatedly writing 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 + * H5Treclaim() may crash on Windows because the Java GC will not be able to collect * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings * once done. */ @@ -1356,7 +1372,7 @@ done: if (utf8) UNPIN_JAVA_STRING(ENVONLY, jstr, utf8); if (writeBuf) { - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, writeBuf); + H5Treclaim(tid, sid, H5P_DEFAULT, writeBuf); HDfree(writeBuf); } if (sid >= 0) @@ -1512,8 +1528,13 @@ Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs UNUSED(clss); +#ifdef H5_NO_DEPRECATED_SYMBOLS + UNUSED(loc_id); + H5_UNIMPLEMENTED(ENVONLY, "H5Aget_num_attrs: not implemented"); +#else if ((retVal = H5Aget_num_attrs((hid_t)loc_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); +#endif done: return (jint)retVal; diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 5500847..b395189 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -340,12 +340,21 @@ Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim (JNIEnv *env, jclass clss, jlong type_id, jlong space_id, jlong xfer_plist_id, jbyteArray buf) { +#ifndef H5_NO_DEPRECATED_SYMBOLS jboolean vlenBufIsCopy; jbyte *vlenBuf = NULL; +#endif herr_t status = FAIL; UNUSED(clss); +#ifdef H5_NO_DEPRECATED_SYMBOLS + UNUSED(type_id); + UNUSED(space_id); + UNUSED(xfer_plist_id); + UNUSED(buf); + H5_UNIMPLEMENTED(ENVONLY, "H5Dvlen_reclaim: not implemented"); +#else if (NULL == buf) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dvlen_reclaim: buffer is NULL"); @@ -353,10 +362,13 @@ Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim if ((status = H5Dvlen_reclaim((hid_t)type_id, (hid_t)space_id, (hid_t)xfer_plist_id, vlenBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); +#endif done: +#ifndef H5_NO_DEPRECATED_SYMBOLS if (vlenBuf) UNPIN_BYTE_ARRAY(ENVONLY, buf, vlenBuf, (status < 0) ? JNI_ABORT : 0); +#endif return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim */ @@ -1172,7 +1184,7 @@ H5DreadVL_str /* * When 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 + * H5Treclaim() may crash on Windows because the Java GC will not be able to collect * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings * once done. */ @@ -1230,7 +1242,7 @@ H5DreadVL_asstr if (mem_space == H5S_ALL) { /* - * Retrieve a valid dataspace for H5Dvlen_reclaim(). + * Retrieve a valid dataspace for H5Treclaim(). */ if ((mem_space = H5Dget_space(did)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1285,7 +1297,7 @@ done: if (h5str.s) h5str_free(&h5str); if (readBuf) { - H5Dvlen_reclaim(tid, mem_space, xfer_plist_id, readBuf); + H5Treclaim(tid, mem_space, xfer_plist_id, readBuf); HDfree(readBuf); } if (close_mem_space) @@ -1504,7 +1516,7 @@ H5DwriteVL_asstr if (mem_space == H5S_ALL) { /* - * Retrieve a valid dataspace for H5Dvlen_reclaim(). + * Retrieve a valid dataspace for H5Treclaim(). */ if ((mem_space = H5Dget_space(did)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1565,7 +1577,7 @@ done: if (utf8) UNPIN_JAVA_STRING(ENVONLY, obj, utf8); if (writeBuf) { - H5Dvlen_reclaim(tid, mem_space, xfer_plist_id, writeBuf); + H5Treclaim(tid, mem_space, xfer_plist_id, writeBuf); HDfree(writeBuf); } if (close_mem_space) diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 4fd6807..2eb3ad5 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -156,15 +156,17 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fis_1hdf5 (JNIEnv *env, jclass clss, jstring name) { +#ifndef H5_NO_DEPRECATED_SYMBOLS const char *fileName = NULL; +#endif htri_t bval = JNI_FALSE; UNUSED(clss); #ifdef H5_NO_DEPRECATED_SYMBOLS + UNUSED(name); H5_UNIMPLEMENTED(ENVONLY, "H5Fis_hdf5: not implemented"); -#endif - +#else if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fis_hdf5: file name is NULL"); @@ -174,10 +176,13 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 H5_LIBRARY_ERROR(ENVONLY); bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; +#endif done: +#ifndef H5_NO_DEPRECATED_SYMBOLS if (fileName) UNPIN_JAVA_STRING(ENVONLY, name, fileName); +#endif return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Fis_1hdf5 */ diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 460f12e..3302b7d 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -980,6 +980,37 @@ done: /* * Class: hdf_hdf5lib_H5 + * Method: H5Treclaim + * Signature: (JJJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Treclaim + (JNIEnv *env, jclass clss, jlong type_id, jlong space_id, + jlong xfer_plist_id, jbyteArray buf) +{ + jboolean bufIsCopy; + jbyte *pinBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Treclaim: buffer is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, buf, pinBuf, &bufIsCopy, "H5Treclaim: buffer not pinned"); + + if ((status = H5Treclaim((hid_t)type_id, (hid_t)space_id, (hid_t)xfer_plist_id, pinBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (pinBuf) + UNPIN_BYTE_ARRAY(ENVONLY, buf, pinBuf, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Treclaim */ + +/* + * Class: hdf_hdf5lib_H5 * Method: _H5Tclose * Signature: (J)I */ diff --git a/java/src/jni/h5tImp.h b/java/src/jni/h5tImp.h index 374d992..a63969b 100644 --- a/java/src/jni/h5tImp.h +++ b/java/src/jni/h5tImp.h @@ -401,6 +401,15 @@ Java_hdf_hdf5lib_H5_H5Tpack /* * Class: hdf_hdf5lib_H5 + * Method: H5Treclaim + * Signature: (JJJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Treclaim + (JNIEnv*, jclass, jlong, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 * Method: _H5Tclose * Signature: (J)I */ diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index af83caa..700f75f 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -2781,7 +2781,7 @@ h5str_dump_simple_dset /* Reclaim any VL memory, if necessary */ if (vl_data) { - if (H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf) < 0) + if (H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf) < 0) H5_LIBRARY_ERROR(ENVONLY); } diff --git a/java/test/TestH5Dparams.java b/java/test/TestH5Dparams.java index a3618f2..621c000 100644 --- a/java/test/TestH5Dparams.java +++ b/java/test/TestH5Dparams.java @@ -113,17 +113,6 @@ public class TestH5Dparams { H5.H5Dvlen_get_buf_size(-1, -1, -1); } - @Test(expected = HDF5LibraryException.class) - public void testH5Dvlen_reclaim_invalid() throws Throwable { - byte[] buf = new byte[2]; - H5.H5Dvlen_reclaim(-1, -1, -1, buf); - } - - @Test(expected = NullPointerException.class) - public void testH5Dvlen_reclaim_null() throws Throwable { - H5.H5Dvlen_reclaim(-1, -1, -1, null); - } - @Test(expected = IllegalArgumentException.class) public void testH5Dget_storage_size_invalid() throws Throwable { H5.H5Dget_storage_size(-1); diff --git a/java/test/TestH5Tparams.java b/java/test/TestH5Tparams.java index 53d3a37..8baccd1 100644 --- a/java/test/TestH5Tparams.java +++ b/java/test/TestH5Tparams.java @@ -274,6 +274,17 @@ public class TestH5Tparams { public void testH5Tpack_invalid() throws Throwable { H5.H5Tpack(-1); } + + @Test(expected = HDF5LibraryException.class) + public void testH5Treclaim_invalid() throws Throwable { + byte[] buf = new byte[2]; + H5.H5Treclaim(-1, -1, -1, buf); + } + + @Test(expected = NullPointerException.class) + public void testH5Treclaim_null() throws Throwable { + H5.H5Treclaim(-1, -1, -1, null); + } @Test(expected = HDF5LibraryException.class) public void testH5Tvlen_create_invalid() throws Throwable { diff --git a/java/test/testfiles/JUnit-TestH5Dparams.txt b/java/test/testfiles/JUnit-TestH5Dparams.txt index 9751be4..9acedd7 100644 --- a/java/test/testfiles/JUnit-TestH5Dparams.txt +++ b/java/test/testfiles/JUnit-TestH5Dparams.txt @@ -7,11 +7,9 @@ JUnit version 4.11 .testH5Dvlen_get_buf_size_invalid .testH5Dcreate_null .testH5Dset_extent_status_null -.testH5Dvlen_reclaim_null .testH5Dcreate_invalid .testH5Dcreate_anon_invalid .testH5Dset_extent_status_invalid -.testH5Dvlen_reclaim_invalid .testH5Dopen_invalid .testH5Dclose_invalid .testH5Dflush_invalid @@ -22,5 +20,5 @@ JUnit version 4.11 Time: XXXX -OK (20 tests) +OK (18 tests) diff --git a/java/test/testfiles/JUnit-TestH5Tparams.txt b/java/test/testfiles/JUnit-TestH5Tparams.txt index e61f1e4..9f725ac 100644 --- a/java/test/testfiles/JUnit-TestH5Tparams.txt +++ b/java/test/testfiles/JUnit-TestH5Tparams.txt @@ -1,5 +1,6 @@ JUnit version 4.11 .testH5Tget_member_type_invalid +.testH5Treclaim_invalid .testH5Tenum_insert_null .testH5Tget_offset_invalid .testH5Tset_precision_invalid @@ -68,9 +69,10 @@ JUnit version 4.11 .testH5Tget_member_index_null .testH5Trefresh_invalid .testH5Tset_sign_invalid +.testH5Treclaim_null .testH5Tenum_insert_name_null Time: XXXX -OK (70 tests) +OK (72 tests) |