diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/Makefile.am | 5 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/H5.java | 17 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/HDF5Constants.java | 3 | ||||
-rw-r--r-- | java/src/jni/h5Constants.c | 2 | ||||
-rw-r--r-- | java/src/jni/h5fImp.c | 24 | ||||
-rw-r--r-- | java/src/jni/h5fImp.h | 9 | ||||
-rw-r--r-- | java/src/jni/h5sImp.c | 4 | ||||
-rw-r--r-- | java/test/TestH5.java | 4 | ||||
-rw-r--r-- | java/test/TestH5F.java | 110 | ||||
-rw-r--r-- | java/test/TestH5P.java | 2 | ||||
-rw-r--r-- | java/test/testfiles/JUnit-TestH5F.txt | 4 |
11 files changed, 126 insertions, 58 deletions
diff --git a/java/Makefile.am b/java/Makefile.am index 7d0e2f0..ed2414d 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -31,6 +31,11 @@ JAVA_API=yes SUBDIRS=src test examples +# Test with just the native connector, with a single pass-through connector +# and with a doubly-stacked pass-through. +VOL_LIST = native "pass_through under_vol=0;under_info={}" \ + "pass_through under_vol=505;under_info={under_vol=0;under_info={}}" + endif include $(top_srcdir)/config/conclude.am diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 57157c2..e874732 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -212,7 +212,7 @@ import hdf.hdf5lib.structs.H5O_info_t; * exception handlers to print out the HDF-5 error stack. * <hr> * - * @version HDF5 1.11.4 <BR> + * @version HDF5 1.11.5 <BR> * <b>See also: <a href ="./hdf.hdf5lib.HDFArray.html"> hdf.hdf5lib.HDFArray</a> </b><BR> * <a href ="./hdf.hdf5lib.HDF5Constants.html"> hdf.hdf5lib.HDF5Constants</a><BR> * <a href ="./hdf.hdf5lib.HDF5CDataTypes.html"> hdf.hdf5lib.HDF5CDataTypes</a><BR> @@ -235,7 +235,7 @@ public class H5 implements java.io.Serializable { * * Make sure to update the versions number when a different library is used. */ - public final static int LIB_VERSION[] = { 1, 11, 4 }; + public final static int LIB_VERSION[] = { 1, 11, 5 }; public final static String H5PATH_PROPERTY_KEY = "hdf.hdf5lib.H5.hdf5lib"; @@ -2968,6 +2968,19 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Fget_intent(long file_id) throws HDF5LibraryException; /** + * H5Fget_fileno retrieves the "file number" for an open file. + * + * @param file_id + * IN: File identifier for a currently-open HDF5 file + * + * @return the unique file number for the file. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native long H5Fget_fileno(long file_id) throws HDF5LibraryException; + + /** * H5Fget_mdc_hit_rate queries the metadata cache of the target file to obtain its hit rate (cache hits / (cache * hits + cache misses)) since the last time hit rate statistics were reset. * diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index a0c2ed6..9294bad 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -216,6 +216,7 @@ public class HDF5Constants { public static final int H5F_LIBVER_EARLIEST = H5F_LIBVER_EARLIEST(); public static final int H5F_LIBVER_V18 = H5F_LIBVER_V18(); public static final int H5F_LIBVER_V110 = H5F_LIBVER_V110(); + public static final int H5F_LIBVER_V112 = H5F_LIBVER_V112(); public static final int H5F_LIBVER_NBOUNDS = H5F_LIBVER_NBOUNDS(); public static final int H5F_LIBVER_LATEST = H5F_LIBVER_LATEST(); public static final int H5F_OBJ_ALL = H5F_OBJ_ALL(); @@ -1049,6 +1050,8 @@ public class HDF5Constants { private static native final int H5F_LIBVER_V110(); + private static native final int H5F_LIBVER_V112(); + private static native final int H5F_LIBVER_NBOUNDS(); private static native final int H5F_LIBVER_LATEST(); diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index 2ac0892..74eb436 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -401,6 +401,8 @@ Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V18(JNIEnv *env, jclass cls){return JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V110(JNIEnv *env, jclass cls){return H5F_LIBVER_V110;} JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V112(JNIEnv *env, jclass cls){return H5F_LIBVER_V112;} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1NBOUNDS(JNIEnv *env, jclass cls){return H5F_LIBVER_NBOUNDS;} JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1LATEST(JNIEnv *env, jclass cls){return H5F_LIBVER_LATEST;} diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index d145c6a..80567d9 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -260,11 +260,11 @@ done: */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fget_1intent - (JNIEnv *env, jclass cls, jlong file_id) + (JNIEnv *env, jclass clss, jlong file_id) { unsigned intent = 0; - UNUSED(cls); + UNUSED(clss); if (H5Fget_intent((hid_t)file_id, &intent) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -275,6 +275,26 @@ done: /* * Class: hdf_hdf5lib_H5 + * Method: H5Fget_fileno + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1fileno + (JNIEnv *env, jclass clss, jlong file_id) +{ + unsigned long fileno = 0; + + UNUSED(clss); + + if (H5Fget_fileno((hid_t)file_id, &fileno) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)fileno; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1fileno */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Fclose * Signature: (J)I */ diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index 410a249..fc02c76 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -104,6 +104,15 @@ Java_hdf_hdf5lib_H5_H5Fget_1intent /* * Class: hdf_hdf5lib_H5 + * Method: H5Fget_fileno + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1fileno + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Fclose * Signature: (J)I */ diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index a91dab2..d8110a1 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -1141,7 +1141,7 @@ Java_hdf_hdf5lib_H5_H5Sencode if (obj_id < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: invalid object ID"); - if ((status = H5Sencode(obj_id, NULL, &buf_size)) < 0) + if ((status = H5Sencode2(obj_id, NULL, &buf_size, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (buf_size == 0) @@ -1150,7 +1150,7 @@ Java_hdf_hdf5lib_H5_H5Sencode if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size))) H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); - if ((status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size)) < 0) + if ((status = H5Sencode2((hid_t) obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize) buf_size))) diff --git a/java/test/TestH5.java b/java/test/TestH5.java index c59101b..1d24724 100644 --- a/java/test/TestH5.java +++ b/java/test/TestH5.java @@ -162,7 +162,7 @@ public class TestH5 { */ @Test public void testH5get_libversion() { - int libversion[] = { 1, 11, 4 }; + int libversion[] = { 1, 11, 5 }; try { H5.H5get_libversion(libversion); @@ -201,7 +201,7 @@ public class TestH5 { */ @Test public void testH5check_version() { - int majnum = 1, minnum = 11, relnum = 4; + int majnum = 1, minnum = 11, relnum = 5; try { H5.H5check_version(majnum, minnum, relnum); diff --git a/java/test/TestH5F.java b/java/test/TestH5F.java index e4f9a30..869b45c 100644 --- a/java/test/TestH5F.java +++ b/java/test/TestH5F.java @@ -14,6 +14,7 @@ package test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -32,6 +33,7 @@ import org.junit.rules.TestName; public class TestH5F { @Rule public TestName testname = new TestName(); private static final String H5_FILE = "testF.h5"; + private static final String H5_FILE2 = "testF2.h5"; private static final int COUNT_OBJ_FILE = 1; private static final int COUNT_OBJ_DATASET = 0; @@ -94,28 +96,12 @@ public class TestH5F { @Test(expected = HDF5LibraryException.class) public void testH5Fget_create_plist_closed() throws Throwable { - long fid = -1; - if (H5fid > 0) { try {H5.H5Fclose(H5fid);} catch (Exception ex) {} - H5fid = -1; - } - - try { - fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, - HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - fail("H5.H5Fopen: " + err); - } - try { - H5.H5Fclose(fid); - } - catch (Exception ex) { } // it should fail because the file was closed. - H5.H5Fget_create_plist(fid); + H5.H5Fget_create_plist(H5fid); } @Test @@ -134,34 +120,17 @@ public class TestH5F { @Test(expected = HDF5LibraryException.class) public void testH5Fget_access_plist_closed() throws Throwable { - long fid = -1; - if (H5fid > 0) { try {H5.H5Fclose(H5fid);} catch (Exception ex) {} - H5fid = -1; - } - - try { - fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, - HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - fail("H5.H5Fopen: " + err); - } - try { - H5.H5Fclose(fid); - } - catch (Exception ex) { } // it should fail because the file was closed. - H5.H5Fget_access_plist(fid); + H5.H5Fget_access_plist(H5fid); } @Test public void testH5Fget_intent_rdwr() { int intent = 0; - long fid = -1; if (H5fid > 0) { try {H5.H5Fclose(H5fid);} catch (Exception ex) {} @@ -169,31 +138,24 @@ public class TestH5F { } try { - fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, + H5fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT); } catch (Throwable err) { fail("H5.H5Fopen: " + err); } try { - intent = H5.H5Fget_intent(fid); + intent = H5.H5Fget_intent(H5fid); } catch (Throwable err) { fail("H5.H5Fget_intent: " + err); } assertEquals(HDF5Constants.H5F_ACC_RDWR, intent); - - try { - H5.H5Fclose(fid); - } - catch (Exception ex) { - } } @Test public void testH5Fget_intent_rdonly() { int intent = 0; - long fid = -1; if (H5fid > 0) { try {H5.H5Fclose(H5fid);} catch (Exception ex) {} @@ -201,24 +163,76 @@ public class TestH5F { } try { - fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDONLY, + H5fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT); } catch (Throwable err) { fail("H5.H5Fopen: " + err); } try { - intent = H5.H5Fget_intent(fid); + intent = H5.H5Fget_intent(H5fid); } catch (Throwable err) { fail("H5.H5Fget_intent: " + err); } assertEquals(HDF5Constants.H5F_ACC_RDONLY, intent); + } + + @Test + public void testH5Fget_fileno_same() { + long fileno1 = 0; + long fileno2 = 0; + long fid1 = -1; + long fid2 = -1; try { - H5.H5Fclose(fid); + fid1 = H5.H5Fcreate(H5_FILE2, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + H5.H5Fflush(fid1, HDF5Constants.H5F_SCOPE_LOCAL); + assertTrue("H5Fcreate failed", fid1 > 0); + fid2 = H5.H5Fopen(H5_FILE2, HDF5Constants.H5F_ACC_RDWR, + HDF5Constants.H5P_DEFAULT); + assertTrue("H5Fopen failed", fid2 > 0); + fileno1 = H5.H5Fget_fileno(fid1); + assertTrue("H5Fget_fileno1="+fileno1, fileno1 > 0); + fileno2 = H5.H5Fget_fileno(fid2); + assertTrue("H5Fget_fileno2="+fileno2, fileno2 > 0); + + assertEquals("fileno1["+fileno1+"]!=fileno2["+fileno2+"]", fileno1, fileno2); + } + catch (Throwable err) { + fail("testH5Fget_fileno_same: " + err); + } + finally { + H5.H5Fclose(fid1); + H5.H5Fclose(fid2); + } + } + + @Test + public void testH5Fget_fileno_diff() { + long fileno1 = 0; + long fileno2 = 0; + long fid2 = -1; + + try { + fid2 = H5.H5Fcreate(H5_FILE2, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + H5.H5Fflush(fid2, HDF5Constants.H5F_SCOPE_LOCAL); + assertTrue("H5Fcreate failed", fid2 > 0); + + fileno1 = H5.H5Fget_fileno(H5fid); + assertTrue("H5Fget_fileno1="+fileno1, fileno1 > 0); + fileno2 = H5.H5Fget_fileno(fid2); + assertTrue("H5Fget_fileno2="+fileno2, fileno2 > 0); + + assertNotEquals("fileno1["+fileno1+"]==fileno2["+fileno2+"]", fileno1, fileno2); + } + catch (Throwable err) { + fail("testH5Fget_fileno_diff: " + err); } - catch (Exception ex) { + finally { + H5.H5Fclose(fid2); } } diff --git a/java/test/TestH5P.java b/java/test/TestH5P.java index 981f34e..e46ed48 100644 --- a/java/test/TestH5P.java +++ b/java/test/TestH5P.java @@ -214,7 +214,7 @@ public class TestH5P { @Test(expected = HDF5FunctionArgumentException.class) public void testH5Pset_libver_bounds_invalidhigh() throws Throwable { - H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_V110, HDF5Constants.H5F_LIBVER_V110+1); + H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_V112, HDF5Constants.H5F_LIBVER_V112+1); } @Test diff --git a/java/test/testfiles/JUnit-TestH5F.txt b/java/test/testfiles/JUnit-TestH5F.txt index 16a423e..f79ac40 100644 --- a/java/test/testfiles/JUnit-TestH5F.txt +++ b/java/test/testfiles/JUnit-TestH5F.txt @@ -1,5 +1,7 @@ JUnit version 4.11 .testH5Fget_access_plist +.testH5Fget_fileno_diff +.testH5Fget_fileno_same .testH5Fget_obj_ids .testH5Fget_intent_rdwr .testH5Fget_access_plist_closed @@ -10,5 +12,5 @@ JUnit version 4.11 Time: XXXX -OK (8 tests) +OK (10 tests) |