diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/src/hdf/hdf5lib/H5.java | 19 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/HDF5Constants.java | 3 | ||||
-rw-r--r-- | java/src/jni/CMakeLists.txt | 4 | ||||
-rw-r--r-- | java/src/jni/h5Constants.c | 2 | ||||
-rw-r--r-- | java/src/jni/h5fImp.c | 29 | ||||
-rw-r--r-- | java/src/jni/h5fImp.h | 9 | ||||
-rw-r--r-- | java/test/TestH5Fbasic.java | 13 | ||||
-rw-r--r-- | java/test/TestH5Fparams.java | 5 | ||||
-rw-r--r-- | java/test/testfiles/JUnit-TestH5Fbasic.txt | 3 | ||||
-rw-r--r-- | java/test/testfiles/JUnit-TestH5Fparams.txt | 3 |
10 files changed, 81 insertions, 9 deletions
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 1138e50..bce0034 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -3077,10 +3077,29 @@ public class H5 implements java.io.Serializable { * - Error from the HDF-5 Library. * @exception NullPointerException * - name is null. + * + * @deprecated As of HDF5 1.10.5 in favor of H5Fis_accessible. **/ public synchronized static native boolean H5Fis_hdf5(String name) throws HDF5LibraryException, NullPointerException; /** + * H5Fis_accessible determines if the file can be opened with the given fapl. + * + * @param name + * IN: File name to check. + * @param file_id + * IN: File identifier for a currently-open HDF5 file + * + * @return true if file is accessible, false if not. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public synchronized static native boolean H5Fis_accessible(String name, long file_id) throws HDF5LibraryException, NullPointerException; + + /** * H5Fmount mounts the file specified by child_id onto the group specified by loc_id and name using the mount * properties plist_id. * diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index b530f4b..0760e7f 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -315,7 +315,6 @@ public class HDF5Constants { public static final int H5I_GROUP = H5I_GROUP(); public static final int H5I_INVALID_HID = H5I_INVALID_HID(); public static final int H5I_NTYPES = H5I_NTYPES(); - public static final int H5I_REFERENCE = H5I_REFERENCE(); public static final int H5I_UNINIT = H5I_UNINIT(); public static final int H5I_VFL = H5I_VFL(); public static final int H5I_VOL = H5I_VOL(); @@ -1222,8 +1221,6 @@ public class HDF5Constants { private static native final int H5I_NTYPES(); - private static native final int H5I_REFERENCE(); - private static native final int H5I_UNINIT(); private static native final int H5I_VFL(); diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt index 7b95e0b..50e76e1 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -48,7 +48,9 @@ set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) ########### JNI libraries always must be built shared ############### add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JAVA_JNI_CHDRS}) -target_include_directories(${HDF5_JAVA_JNI_LIB_TARGET} PRIVATE ${HDF5_BINARY_DIR} ${HDF5_JAVA_JNI_SOURCE_DIR}) +target_include_directories(${HDF5_JAVA_JNI_LIB_TARGET} + PRIVATE "${HDF5_BINARY_DIR};${HDF5_JAVA_JNI_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" +) TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED) target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni) diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index fdec61a..b13dc76 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -603,8 +603,6 @@ Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASET(JNIEnv *env, jclass cls) { return H5 JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1ATTR(JNIEnv *env, jclass cls) { return H5I_ATTR; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1REFERENCE(JNIEnv *env, jclass cls) { return H5I_REFERENCE; } -JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1VFL(JNIEnv *env, jclass cls) { return H5I_VFL; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1VOL(JNIEnv *env, jclass cls) { return H5I_VOL; } diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 9d68290..248e654 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -168,6 +168,33 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 /* * Class: hdf_hdf5lib_H5 + * Method: H5Fis_accessible + * Signature: (Ljava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fis_1accessible + (JNIEnv *env, jclass clss, jstring name, jlong file_id) +{ + htri_t bval = JNI_FALSE; + const char *fileName; + + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + bval = H5Fis_accessible(fileName, (hid_t)file_id); + + UNPIN_JAVA_STRING(name, fileName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + } + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Fis_1accessible */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Fget_create_plist * Signature: (J)J */ @@ -177,7 +204,7 @@ Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist { hid_t retVal = -1; - retVal = H5Fget_create_plist((hid_t)file_id ); + retVal = H5Fget_create_plist((hid_t)file_id); if (retVal < 0) h5libraryError(env); diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index fcfdedf..af0fa1d 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -68,6 +68,15 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 /* * Class: hdf_hdf5lib_H5 + * Method: H5Fis_accessible + * Signature: (Ljava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fis_1ccessible + (JNIEnv*, jclass, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Fget_create_plist * Signature: (J)J */ diff --git a/java/test/TestH5Fbasic.java b/java/test/TestH5Fbasic.java index 11d6644..a5afb6e 100644 --- a/java/test/TestH5Fbasic.java +++ b/java/test/TestH5Fbasic.java @@ -81,6 +81,19 @@ public class TestH5Fbasic { assertTrue(isH5 == true); } + @Test + public void testH5Fis_accessible() { + boolean isH5 = false; + + try { + isH5 = H5.H5Fis_accessible(H5_FILE, HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fis_accessible failed on " + H5_FILE + ": " + err); + } + assertTrue(isH5 == true); + } + @Test(expected = HDF5LibraryException.class) public void testH5Fcreate_EXCL() throws Throwable { H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_EXCL, diff --git a/java/test/TestH5Fparams.java b/java/test/TestH5Fparams.java index fffded1..3d64aa9 100644 --- a/java/test/TestH5Fparams.java +++ b/java/test/TestH5Fparams.java @@ -60,6 +60,11 @@ public class TestH5Fparams { } @Test(expected = NullPointerException.class) + public void testH5Fis_accessible_null() throws Throwable { + H5.H5Fis_accessible(null, -1); + } + + @Test(expected = NullPointerException.class) public void testH5Fmount_null() throws Throwable { H5.H5Fmount(-1, null, -1, HDF5Constants.H5P_DEFAULT); } diff --git a/java/test/testfiles/JUnit-TestH5Fbasic.txt b/java/test/testfiles/JUnit-TestH5Fbasic.txt index 467e2fb..2654624 100644 --- a/java/test/testfiles/JUnit-TestH5Fbasic.txt +++ b/java/test/testfiles/JUnit-TestH5Fbasic.txt @@ -9,6 +9,7 @@ JUnit version 4.11 .testH5Freopen_closed .testH5Freset_mdc_hit_rate_stats .testH5Fget_name +.testH5Fis_accessible .testH5Fcreate .testH5Fclear_elink_file_cache .testH5Fclose_twice @@ -17,5 +18,5 @@ JUnit version 4.11 Time: XXXX -OK (15 tests) +OK (16 tests) diff --git a/java/test/testfiles/JUnit-TestH5Fparams.txt b/java/test/testfiles/JUnit-TestH5Fparams.txt index 9d35220..e91cbdc 100644 --- a/java/test/testfiles/JUnit-TestH5Fparams.txt +++ b/java/test/testfiles/JUnit-TestH5Fparams.txt @@ -1,4 +1,5 @@ JUnit version 4.11 +.testH5Fis_accessible_null .testH5Fcreate_null .testH5Fflush_local .testH5Fget_info @@ -13,5 +14,5 @@ JUnit version 4.11 Time: XXXX -OK (11 tests) +OK (12 tests) |