diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-01-16 21:29:34 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-01-16 21:29:34 (GMT) |
commit | a92c735c9b57049e8c4037d3490f7e10f8eef4d6 (patch) | |
tree | 74da25151de6d1e32329dfcd62e17c863e2e3de1 /java/src | |
parent | 024f7ba09250110c19b070c9699cfbc0f9dc2b96 (diff) | |
download | hdf5-a92c735c9b57049e8c4037d3490f7e10f8eef4d6.zip hdf5-a92c735c9b57049e8c4037d3490f7e10f8eef4d6.tar.gz hdf5-a92c735c9b57049e8c4037d3490f7e10f8eef4d6.tar.bz2 |
Squashed commit of the token_refactoring branch:
Diffstat (limited to 'java/src')
40 files changed, 1430 insertions, 847 deletions
diff --git a/java/src/Makefile.am b/java/src/Makefile.am index fcdeae9..b7ad4bd 100644 --- a/java/src/Makefile.am +++ b/java/src/Makefile.am @@ -51,10 +51,10 @@ hdf5_java_JAVA = \ ${pkgpath}/callbacks/H5D_iterate_t.java \ ${pkgpath}/callbacks/H5E_walk_cb.java \ ${pkgpath}/callbacks/H5E_walk_t.java \ - ${pkgpath}/callbacks/H5L_iterate_cb.java \ ${pkgpath}/callbacks/H5L_iterate_t.java \ - ${pkgpath}/callbacks/H5O_iterate_cb.java \ + ${pkgpath}/callbacks/H5L_iterate_opdata_t.java \ ${pkgpath}/callbacks/H5O_iterate_t.java \ + ${pkgpath}/callbacks/H5O_iterate_opdata_t.java \ ${pkgpath}/callbacks/H5P_cls_close_func_cb.java \ ${pkgpath}/callbacks/H5P_cls_close_func_t.java \ ${pkgpath}/callbacks/H5P_cls_copy_func_cb.java \ @@ -103,6 +103,8 @@ hdf5_java_JAVA = \ ${pkgpath}/structs/H5G_info_t.java \ ${pkgpath}/structs/H5L_info_t.java \ ${pkgpath}/structs/H5O_info_t.java \ + ${pkgpath}/structs/H5O_native_info_t.java \ + ${pkgpath}/structs/H5O_token_t.java \ ${pkgpath}/structs/H5O_hdr_info_t.java \ ${pkgpath}/structs/H5AC_cache_config_t.java \ ${pkgpath}/H5.java \ diff --git a/java/src/hdf/hdf5lib/CMakeLists.txt b/java/src/hdf/hdf5lib/CMakeLists.txt index be8f60a..b0293fb 100644 --- a/java/src/hdf/hdf5lib/CMakeLists.txt +++ b/java/src/hdf/hdf5lib/CMakeLists.txt @@ -18,10 +18,10 @@ set (HDF5_JAVA_HDF_HDF5_CALLBACKS_SOURCES callbacks/H5D_iterate_t.java callbacks/H5E_walk_cb.java callbacks/H5E_walk_t.java - callbacks/H5L_iterate_cb.java callbacks/H5L_iterate_t.java - callbacks/H5O_iterate_cb.java + callbacks/H5L_iterate_opdata_t.java callbacks/H5O_iterate_t.java + callbacks/H5O_iterate_opdata_t.java callbacks/H5P_cls_close_func_cb.java callbacks/H5P_cls_close_func_t.java callbacks/H5P_cls_copy_func_cb.java @@ -79,6 +79,8 @@ set (HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES structs/H5L_info_t.java structs/H5O_hdr_info_t.java structs/H5O_info_t.java + structs/H5O_native_info_t.java + structs/H5O_token_t.java ) set (HDF5_JAVA_HDF_HDF5_SOURCES diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index ba10f5e..5b704dd 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -24,10 +24,10 @@ import hdf.hdf5lib.callbacks.H5D_iterate_cb; import hdf.hdf5lib.callbacks.H5D_iterate_t; import hdf.hdf5lib.callbacks.H5E_walk_cb; import hdf.hdf5lib.callbacks.H5E_walk_t; -import hdf.hdf5lib.callbacks.H5L_iterate_cb; import hdf.hdf5lib.callbacks.H5L_iterate_t; -import hdf.hdf5lib.callbacks.H5O_iterate_cb; +import hdf.hdf5lib.callbacks.H5L_iterate_opdata_t; import hdf.hdf5lib.callbacks.H5O_iterate_t; +import hdf.hdf5lib.callbacks.H5O_iterate_opdata_t; import hdf.hdf5lib.callbacks.H5P_cls_close_func_cb; import hdf.hdf5lib.callbacks.H5P_cls_close_func_t; import hdf.hdf5lib.callbacks.H5P_cls_copy_func_cb; @@ -55,6 +55,8 @@ import hdf.hdf5lib.structs.H5FD_ros3_fapl_t; import hdf.hdf5lib.structs.H5G_info_t; import hdf.hdf5lib.structs.H5L_info_t; import hdf.hdf5lib.structs.H5O_info_t; +import hdf.hdf5lib.structs.H5O_native_info_t; +import hdf.hdf5lib.structs.H5O_token_t; /** * This class is the Java interface for the HDF5 library. @@ -3577,8 +3579,8 @@ public class H5 implements java.io.Serializable { * OUT: Names of all objects under the group, name. * @param objTypes * OUT: Types of all objects under the group, name. - * @param objRef - * OUT: Reference number of all objects under the group, name. + * @param tokens + * OUT: Object token of all objects under the group, name. * * @return the number of items found * @@ -3588,26 +3590,26 @@ public class H5 implements java.io.Serializable { * - name is null. */ public synchronized static int H5Gget_obj_info_all(long loc_id, String name, String[] objNames, int[] objTypes, - long[] objRef) throws HDF5LibraryException, NullPointerException { + H5O_token_t[] tokens) throws HDF5LibraryException, NullPointerException { if (objNames == null) { throw new NullPointerException("H5Gget_obj_info_all(): name array is null"); } - return H5Gget_obj_info_all(loc_id, name, objNames, objTypes, null, null, objRef, HDF5Constants.H5_INDEX_NAME); + return H5Gget_obj_info_all(loc_id, name, objNames, objTypes, null, null, tokens, HDF5Constants.H5_INDEX_NAME); } public synchronized static int H5Gget_obj_info_all(long loc_id, String name, String[] oname, int[] otype, - int[] ltype, long[] ref, int indx_type) throws HDF5LibraryException, NullPointerException { - return H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, null, ref, indx_type, -1); + int[] ltype, H5O_token_t[] tokens, int indx_type) throws HDF5LibraryException, NullPointerException { + return H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, null, tokens, indx_type, -1); } public synchronized static int H5Gget_obj_info_all(long loc_id, String name, String[] oname, int[] otype, - int[] ltype, long[] fno, long[] ref, int indx_type) throws HDF5LibraryException, NullPointerException { - return H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, fno, ref, oname.length, indx_type, -1); + int[] ltype, long[] fno, H5O_token_t[] tokens, int indx_type) throws HDF5LibraryException, NullPointerException { + return H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, fno, tokens, oname.length, indx_type, -1); } public synchronized static int H5Gget_obj_info_full(long loc_id, String name, String[] oname, int[] otype, - int[] ltype, long[] fno, long[] ref, int indx_type, int indx_order) throws HDF5LibraryException, + int[] ltype, long[] fno, H5O_token_t[] tokens, int indx_type, int indx_order) throws HDF5LibraryException, NullPointerException { if (oname == null) { throw new NullPointerException("H5Gget_obj_info_full(): name array is null"); @@ -3629,7 +3631,7 @@ public class H5 implements java.io.Serializable { ltype = new int[otype.length]; if (fno == null) - fno = new long[ref.length]; + fno = new long[tokens.length]; if (indx_type < 0) indx_type = HDF5Constants.H5_INDEX_NAME; @@ -3638,7 +3640,7 @@ public class H5 implements java.io.Serializable { indx_order = HDF5Constants.H5_ITER_INC; log.trace("H5Gget_obj_info_full: oname_len={}", oname.length); - int status = H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, fno, ref, oname.length, indx_type, + int status = H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, fno, tokens, oname.length, indx_type, indx_order); for (int indx = 0; indx < oname.length; indx++) log.trace("H5Gget_obj_info_full: oname={}", oname[indx]); @@ -3646,7 +3648,7 @@ public class H5 implements java.io.Serializable { } private synchronized static native int H5Gget_obj_info_full(long loc_id, String name, String[] oname, int[] otype, - int[] ltype, long[] fno, long[] ref, int n, int indx_type, int indx_order) throws HDF5LibraryException, + int[] ltype, long[] fno, H5O_token_t[] tokens, int n, int indx_type, int indx_order) throws HDF5LibraryException, NullPointerException; /** @@ -3701,8 +3703,8 @@ public class H5 implements java.io.Serializable { * OUT: Types of all objects under the group, name. * @param lnkTypes * OUT: Types of all links under the group, name. - * @param objRef - * OUT: Reference number of all objects under the group, name. + * @param objToken + * OUT: Object token of all objects under the group, name. * @param objMax * IN: Maximum number of all objects under the group, name. * @@ -3714,7 +3716,7 @@ public class H5 implements java.io.Serializable { * - name is null. */ public synchronized static int H5Gget_obj_info_max(long loc_id, String[] objNames, int[] objTypes, int[] lnkTypes, - long[] objRef, long objMax) throws HDF5LibraryException, NullPointerException { + H5O_token_t[] objToken, long objMax) throws HDF5LibraryException, NullPointerException { if (objNames == null) { throw new NullPointerException("H5Gget_obj_info_max(): name array is null"); } @@ -3739,11 +3741,11 @@ public class H5 implements java.io.Serializable { throw new HDF5LibraryException("H5Gget_obj_info_max(): name and type array sizes are different"); } - return H5Gget_obj_info_max(loc_id, objNames, objTypes, lnkTypes, objRef, objMax, objNames.length); + return H5Gget_obj_info_max(loc_id, objNames, objTypes, lnkTypes, objToken, objMax, objNames.length); } private synchronized static native int H5Gget_obj_info_max(long loc_id, String[] oname, int[] otype, int[] ltype, - long[] ref, long amax, int n) throws HDF5LibraryException, NullPointerException; + H5O_token_t[] tokens, long amax, int n) throws HDF5LibraryException, NullPointerException; /** * H5Gn_members report the number of objects in a Group. The 'objects' include everything that will be visited by @@ -4340,8 +4342,8 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native int H5Literate(long grp_id, int idx_type, int order, long idx, H5L_iterate_cb op, - H5L_iterate_t op_data) throws HDF5LibraryException; + public synchronized static native int H5Literate(long grp_id, int idx_type, int order, long idx, H5L_iterate_t op, + H5L_iterate_opdata_t op_data) throws HDF5LibraryException; /** * H5Literate_by_name iterates through links in a group. @@ -4372,7 +4374,7 @@ public class H5 implements java.io.Serializable { * - group_name is null. **/ public synchronized static native int H5Literate_by_name(long grp_id, String group_name, int idx_type, int order, - long idx, H5L_iterate_cb op, H5L_iterate_t op_data, long lapl_id) throws HDF5LibraryException, + long idx, H5L_iterate_t op, H5L_iterate_opdata_t op_data, long lapl_id) throws HDF5LibraryException, NullPointerException; /** @@ -4419,8 +4421,8 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native int H5Lvisit(long grp_id, int idx_type, int order, H5L_iterate_cb op, - H5L_iterate_t op_data) throws HDF5LibraryException; + public synchronized static native int H5Lvisit(long grp_id, int idx_type, int order, H5L_iterate_t op, + H5L_iterate_opdata_t op_data) throws HDF5LibraryException; /** * H5Lvisit_by_name recursively visits all links starting from a specified group. @@ -4449,7 +4451,7 @@ public class H5 implements java.io.Serializable { * - group_name is null. **/ public synchronized static native int H5Lvisit_by_name(long loc_id, String group_name, int idx_type, int order, - H5L_iterate_cb op, H5L_iterate_t op_data, long lapl_id) throws HDF5LibraryException, NullPointerException; + H5L_iterate_t op, H5L_iterate_opdata_t op_data, long lapl_id) throws HDF5LibraryException, NullPointerException; /** @@ -4666,6 +4668,52 @@ public class H5 implements java.io.Serializable { NullPointerException; /** + * H5Oget_info_by_name retrieves the metadata for an object, identifying the object by location and relative name. + * + * @param loc_id + * IN: File or group identifier specifying location of group in which object is located + * @param name + * IN: Relative name of group + * @param lapl_id + * IN: Access property list identifier for the link pointing to the object (Not currently used; pass as + * H5P_DEFAULT.) + * + * @return object information + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public static H5O_info_t H5Oget_info_by_name(long loc_id, String name, long lapl_id) + throws HDF5LibraryException, NullPointerException { + return H5Oget_info_by_name(loc_id, name, HDF5Constants.H5O_INFO_ALL, lapl_id); + } + + /** + * H5Oget_info_by_name retrieves the metadata for an object, identifying the object by location and relative name. + * + * @param loc_id + * IN: File or group identifier specifying location of group in which object is located + * @param name + * IN: Relative name of group + * @param fields + * IN: Object fields to select + * @param lapl_id + * IN: Access property list identifier for the link pointing to the object (Not currently used; pass as + * H5P_DEFAULT.) + * + * @return object information + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public synchronized static native H5O_info_t H5Oget_info_by_name(long loc_id, String name, int fields, long lapl_id) + throws HDF5LibraryException, NullPointerException; + + /** * H5Oget_info_by_idx retrieves the metadata for an object, identifying the object by an index position. * * @param loc_id @@ -4724,7 +4772,47 @@ public class H5 implements java.io.Serializable { int order, long n, int fields, long lapl_id) throws HDF5LibraryException, NullPointerException; /** - * H5Oget_info_by_name retrieves the metadata for an object, identifying the object by location and relative name. + * H5Oget_native_info retrieves the native HDF5-specific metadata for an HDF5 object specified by an identifier. + * Native HDF5-specific metadata includes things like object header information and object storage layout information. + * + * @param loc_id + * IN: Identifier for target object + * + * @return object information + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public static H5O_native_info_t H5Oget_native_info(long loc_id) throws HDF5LibraryException, + NullPointerException { + return H5Oget_native_info(loc_id, HDF5Constants.H5O_NATIVE_INFO_ALL); + } + + /** + * H5Oget_native_info retrieves the native HDF5-specific metadata for an HDF5 object specified by an identifier. + * Native HDF5-specific metadata includes things like object header information and object storage layout information. + * + * @param loc_id + * IN: Identifier for target object + * @param fields + * IN: Object fields to select + * + * @return object information + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public synchronized static native H5O_native_info_t H5Oget_native_info(long loc_id, int fields) throws HDF5LibraryException, + NullPointerException; + + /** + * H5Oget_native_info_by_name retrieves the native HDF5-specific metadata for an HDF5 object, identifying the object + * by location and relative name. Native HDF5-specific metadata includes things like object header information and + * object storage layout information. * * @param loc_id * IN: File or group identifier specifying location of group in which object is located @@ -4741,13 +4829,15 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - name is null. **/ - public static H5O_info_t H5Oget_info_by_name(long loc_id, String name, long lapl_id) + public static H5O_native_info_t H5Oget_native_info_by_name(long loc_id, String name, long lapl_id) throws HDF5LibraryException, NullPointerException { - return H5Oget_info_by_name(loc_id, name, HDF5Constants.H5O_INFO_ALL, lapl_id); + return H5Oget_native_info_by_name(loc_id, name, HDF5Constants.H5O_NATIVE_INFO_ALL, lapl_id); } /** - * H5Oget_info_by_name retrieves the metadata for an object, identifying the object by location and relative name. + * H5Oget_native_info_by_name retrieves the native HDF5-specific metadata for an HDF5 object, identifying the object + * by location and relative name. Native HDF5-specific metadata includes things like object header information and + * object storage layout information. * * @param loc_id * IN: File or group identifier specifying location of group in which object is located @@ -4766,10 +4856,72 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - name is null. **/ - public synchronized static native H5O_info_t H5Oget_info_by_name(long loc_id, String name, int fields, long lapl_id) + public synchronized static native H5O_native_info_t H5Oget_native_info_by_name(long loc_id, String name, int fields, long lapl_id) throws HDF5LibraryException, NullPointerException; /** + * H5Oget_native_info_by_idx retrieves the native HDF5-specific metadata for an HDF5 object, identifying the object + * by an index position. Native HDF5-specific metadata includes things like object header information and + * object storage layout information. + * + * @param loc_id + * IN: File or group identifier + * @param group_name + * IN: Name of group, relative to loc_id, in which object is located + * @param idx_type + * IN: Type of index by which objects are ordered + * @param order + * IN: Order of iteration within index + * @param n + * IN: Object to open + * @param lapl_id + * IN: Access property list identifier for the link pointing to the object (Not currently used; pass as + * H5P_DEFAULT.) + * + * @return object information + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public static H5O_native_info_t H5Oget_native_info_by_idx(long loc_id, String group_name, int idx_type, + int order, long n, long lapl_id) throws HDF5LibraryException, NullPointerException { + return H5Oget_native_info_by_idx(loc_id, group_name, idx_type, order, n, HDF5Constants.H5O_NATIVE_INFO_ALL, lapl_id); + } + + /** + * H5Oget_native_info_by_idx retrieves the native HDF5-specific metadata for an HDF5 object, identifying the object + * by an index position. Native HDF5-specific metadata includes things like object header information and + * object storage layout information. + * + * @param loc_id + * IN: File or group identifier + * @param group_name + * IN: Name of group, relative to loc_id, in which object is located + * @param idx_type + * IN: Type of index by which objects are ordered + * @param order + * IN: Order of iteration within index + * @param n + * IN: Object to open + * @param fields + * IN: Object fields to select + * @param lapl_id + * IN: Access property list identifier for the link pointing to the object (Not currently used; pass as + * H5P_DEFAULT.) + * + * @return object information + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public synchronized static native H5O_native_info_t H5Oget_native_info_by_idx(long loc_id, String group_name, int idx_type, + int order, long n, int fields, long lapl_id) throws HDF5LibraryException, NullPointerException; + + /** * H5Olink creates a new hard link to an object in an HDF5 file. * * @param obj_id @@ -4843,7 +4995,7 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - name is null. **/ - public static int H5Ovisit(long obj_id, int idx_type, int order, H5O_iterate_cb op, H5O_iterate_t op_data) + public static int H5Ovisit(long obj_id, int idx_type, int order, H5O_iterate_t op, H5O_iterate_opdata_t op_data) throws HDF5LibraryException, NullPointerException { return H5Ovisit(obj_id, idx_type, order, op, op_data, HDF5Constants.H5O_INFO_ALL); } @@ -4872,8 +5024,8 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - name is null. **/ - public synchronized static native int H5Ovisit(long obj_id, int idx_type, int order, H5O_iterate_cb op, - H5O_iterate_t op_data, int fields) throws HDF5LibraryException, NullPointerException; + public synchronized static native int H5Ovisit(long obj_id, int idx_type, int order, H5O_iterate_t op, + H5O_iterate_opdata_t op_data, int fields) throws HDF5LibraryException, NullPointerException; /** * H5Ovisit_by_name recursively visits all objects starting from a specified object. @@ -4902,7 +5054,7 @@ public class H5 implements java.io.Serializable { * - name is null. **/ public static int H5Ovisit_by_name(long loc_id, String obj_name, int idx_type, int order, - H5O_iterate_cb op, H5O_iterate_t op_data, long lapl_id) throws HDF5LibraryException, NullPointerException { + H5O_iterate_t op, H5O_iterate_opdata_t op_data, long lapl_id) throws HDF5LibraryException, NullPointerException { return H5Ovisit_by_name(loc_id, obj_name, idx_type, order, op, op_data, HDF5Constants.H5O_INFO_ALL, lapl_id); } @@ -4935,7 +5087,7 @@ public class H5 implements java.io.Serializable { * - name is null. **/ public synchronized static native int H5Ovisit_by_name(long loc_id, String obj_name, int idx_type, int order, - H5O_iterate_cb op, H5O_iterate_t op_data, int fields, long lapl_id) throws HDF5LibraryException, NullPointerException; + H5O_iterate_t op, H5O_iterate_opdata_t op_data, int fields, long lapl_id) throws HDF5LibraryException, NullPointerException; /** @@ -4977,26 +5129,28 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Oincr_refcount(long object_id) throws HDF5LibraryException; /** - * H5Oopen_by_addr opens a group, dataset, or named datatype using its address within an HDF5 file. + * H5Oopen_by_token opens a group, dataset, or named datatype using its object token within an HDF5 file. * * @param loc_id IN: File or group identifier - * @param addr IN: Object's address in the file + * @param token IN: Object's token in the file * * @return an object identifier for the opened object * * @exception HDF5LibraryException - Error from the HDF-5 Library. **/ - public static long H5Oopen_by_addr(long loc_id, long addr) throws HDF5LibraryException { - long id = _H5Oopen_by_addr(loc_id, addr); + public static long H5Oopen_by_token(long loc_id, H5O_token_t token) throws HDF5LibraryException { + long id = _H5Oopen_by_token(loc_id, token); + if (id > 0) { - log.trace("OPEN_IDS: H5Oopen_by_addr add {}", id); + log.trace("OPEN_IDS: H5Oopen_by_token add {}", id); OPEN_IDS.add(id); log.trace("OPEN_IDS: {}", OPEN_IDS.size()); } + return id; } - private synchronized static native long _H5Oopen_by_addr(long loc_id, long addr) + private synchronized static native long _H5Oopen_by_token(long loc_id, H5O_token_t token) throws HDF5LibraryException, NullPointerException; /** @@ -5060,6 +5214,12 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Oenable_mdc_flushes(long object_id); public synchronized static native boolean H5Oare_mdc_flushes_disabled(long object_id); + // /////// unimplemented //////// + // herr_t H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, + // int *cmp_value); + // herr_t H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str); + // herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token); + // //////////////////////////////////////////////////////////// // // // H5P: Property List Interface Functions // @@ -10736,7 +10896,8 @@ public class H5 implements java.io.Serializable { public synchronized static native long H5VLregister_connector_by_name(String connector_name, long vipl_id); public synchronized static native long H5VLregister_connector_by_value(int connector_value, long vipl_id); public synchronized static native boolean H5VLis_connector_registered(String name); - public synchronized static native long H5VLget_connector_id(String name); + public synchronized static native long H5VLget_connector_id(long object_id); + public synchronized static native long H5VLget_connector_id_by_name(String name); public synchronized static native String H5VLget_connector_name(long object_id); public synchronized static native void H5VLclose(long connector_id); public synchronized static native void H5VLunregister_connector(long connector_id); diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index 4aeeb98..beba1d1 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -14,6 +14,8 @@ package hdf.hdf5lib; +import hdf.hdf5lib.structs.H5O_token_t; + /** * /** This class contains C constants and enumerated types of HDF5 library. The * values of these constants are obtained from the library by calling J2C(int @@ -344,9 +346,10 @@ public class HDF5Constants { public static final int H5O_INFO_BASIC = H5O_INFO_BASIC(); public static final int H5O_INFO_TIME = H5O_INFO_TIME(); public static final int H5O_INFO_NUM_ATTRS = H5O_INFO_NUM_ATTRS(); - public static final int H5O_INFO_HDR = H5O_INFO_HDR(); - public static final int H5O_INFO_META_SIZE = H5O_INFO_META_SIZE(); public static final int H5O_INFO_ALL = H5O_INFO_ALL(); + public static final int H5O_NATIVE_INFO_HDR = H5O_NATIVE_INFO_HDR(); + public static final int H5O_NATIVE_INFO_META_SIZE = H5O_NATIVE_INFO_META_SIZE(); + public static final int H5O_NATIVE_INFO_ALL = H5O_NATIVE_INFO_ALL(); public static final int H5O_SHMESG_NONE_FLAG = H5O_SHMESG_NONE_FLAG(); public static final int H5O_SHMESG_SDSPACE_FLAG = H5O_SHMESG_SDSPACE_FLAG(); public static final int H5O_SHMESG_DTYPE_FLAG = H5O_SHMESG_DTYPE_FLAG(); @@ -359,6 +362,8 @@ public class HDF5Constants { public static final int H5O_TYPE_DATASET = H5O_TYPE_DATASET(); public static final int H5O_TYPE_NAMED_DATATYPE = H5O_TYPE_NAMED_DATATYPE(); public static final int H5O_TYPE_NTYPES = H5O_TYPE_NTYPES(); + public static final int H5O_MAX_TOKEN_SIZE = H5O_MAX_TOKEN_SIZE(); + public static final H5O_token_t H5O_TOKEN_UNDEF = H5O_TOKEN_UNDEF(); public static final long H5P_ROOT = H5P_ROOT(); public static final long H5P_OBJECT_CREATE = H5P_OBJECT_CREATE(); @@ -1308,11 +1313,13 @@ public class HDF5Constants { private static native final int H5O_INFO_NUM_ATTRS(); - private static native final int H5O_INFO_HDR(); + private static native final int H5O_INFO_ALL(); - private static native final int H5O_INFO_META_SIZE(); + private static native final int H5O_NATIVE_INFO_HDR(); - private static native final int H5O_INFO_ALL(); + private static native final int H5O_NATIVE_INFO_META_SIZE(); + + private static native final int H5O_NATIVE_INFO_ALL(); private static native final int H5O_SHMESG_NONE_FLAG(); @@ -1338,6 +1345,10 @@ public class HDF5Constants { private static native final int H5O_TYPE_NTYPES(); + private static native final int H5O_MAX_TOKEN_SIZE(); + + private static native final H5O_token_t H5O_TOKEN_UNDEF(); + private static native final long H5P_ROOT(); private static native final long H5P_OBJECT_CREATE(); diff --git a/java/src/hdf/hdf5lib/callbacks/H5L_iterate_cb.java b/java/src/hdf/hdf5lib/callbacks/H5L_iterate_opdata_t.java index ec71911..ad9ad8c 100644 --- a/java/src/hdf/hdf5lib/callbacks/H5L_iterate_cb.java +++ b/java/src/hdf/hdf5lib/callbacks/H5L_iterate_opdata_t.java @@ -13,9 +13,6 @@ package hdf.hdf5lib.callbacks; -import hdf.hdf5lib.structs.H5L_info_t; +public interface H5L_iterate_opdata_t { -//Information class for link callback(for H5Lvisit/H5Lvisit_by_name) -public interface H5L_iterate_cb extends Callbacks { - int callback(long group, String name, H5L_info_t info, H5L_iterate_t op_data); } diff --git a/java/src/hdf/hdf5lib/callbacks/H5L_iterate_t.java b/java/src/hdf/hdf5lib/callbacks/H5L_iterate_t.java index 28ffb8a..f92fbc4 100644 --- a/java/src/hdf/hdf5lib/callbacks/H5L_iterate_t.java +++ b/java/src/hdf/hdf5lib/callbacks/H5L_iterate_t.java @@ -13,8 +13,9 @@ package hdf.hdf5lib.callbacks; -public interface H5L_iterate_t { -/** public ArrayList iterdata = new ArrayList(); - * Any derived interfaces must define the single public variable as above. - */ +import hdf.hdf5lib.structs.H5L_info_t; + +// Information class for link callback (for H5Lvisit/H5Lvisit_by_name). +public interface H5L_iterate_t extends Callbacks { + int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data); } diff --git a/java/src/hdf/hdf5lib/callbacks/H5O_iterate_cb.java b/java/src/hdf/hdf5lib/callbacks/H5O_iterate_opdata_t.java index 89cf206..e1c47b5 100644 --- a/java/src/hdf/hdf5lib/callbacks/H5O_iterate_cb.java +++ b/java/src/hdf/hdf5lib/callbacks/H5O_iterate_opdata_t.java @@ -13,9 +13,6 @@ package hdf.hdf5lib.callbacks; -import hdf.hdf5lib.structs.H5O_info_t; +public interface H5O_iterate_opdata_t { -//Information class for link callback(for H5Ovisit/H5Ovisit_by_name) -public interface H5O_iterate_cb extends Callbacks { - int callback(long group, String name, H5O_info_t info, H5O_iterate_t op_data); } diff --git a/java/src/hdf/hdf5lib/callbacks/H5O_iterate_t.java b/java/src/hdf/hdf5lib/callbacks/H5O_iterate_t.java index 1491b09..9a55106 100644 --- a/java/src/hdf/hdf5lib/callbacks/H5O_iterate_t.java +++ b/java/src/hdf/hdf5lib/callbacks/H5O_iterate_t.java @@ -13,8 +13,9 @@ package hdf.hdf5lib.callbacks; -public interface H5O_iterate_t { -/** public ArrayList iterdata = new ArrayList(); - * Any derived interfaces must define the single public variable as above. - */ +import hdf.hdf5lib.structs.H5O_info_t; + +// Information class for link callback(for H5Ovisit/H5Ovisit_by_name) +public interface H5O_iterate_t extends Callbacks { + int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data); } diff --git a/java/src/hdf/hdf5lib/structs/H5L_info_t.java b/java/src/hdf/hdf5lib/structs/H5L_info_t.java index 3bbb189..377e617 100644 --- a/java/src/hdf/hdf5lib/structs/H5L_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5L_info_t.java @@ -15,22 +15,39 @@ package hdf.hdf5lib.structs; import java.io.Serializable; -//Information struct for link (for H5Lget_info/H5Lget_info_by_idx) -public class H5L_info_t implements Serializable{ +import hdf.hdf5lib.HDF5Constants; + +// Information struct for link (for H5Lget_info/H5Lget_info_by_idx) +public class H5L_info_t implements Serializable { private static final long serialVersionUID = -4754320605310155033L; - public int type; - public boolean corder_valid; - public long corder; - public int cset; - public long address_val_size; + public int type; + public boolean corder_valid; + public long corder; + public int cset; + public H5O_token_t token; + public long val_size; + + // Constructor for using object token portion of C union + H5L_info_t (int type, boolean corder_valid, long corder, + int cset, H5O_token_t token) + { + this.type = type; + this.corder_valid = corder_valid; + this.corder = corder; + this.cset = cset; + this.token = token; + this.val_size = -1; + } + // Constructor for using val_size portion of C union H5L_info_t (int type, boolean corder_valid, long corder, - int cset, long address_val_size) + int cset, long val_size) { this.type = type; this.corder_valid = corder_valid; this.corder = corder; this.cset = cset; - this.address_val_size = address_val_size; + this.token = HDF5Constants.H5O_TOKEN_UNDEF; + this.val_size = val_size; } } diff --git a/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java b/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java index a39c1ed..8d0cc24 100644 --- a/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java @@ -16,7 +16,7 @@ package hdf.hdf5lib.structs; import java.io.Serializable; // Information struct for object header metadata (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) -public class H5O_hdr_info_t implements Serializable{ +public class H5O_hdr_info_t implements Serializable { private static final long serialVersionUID = 7883826382952577189L; public int version; /* Version number of header format in file */ public int nmesgs; /* Number of object header messages */ @@ -44,4 +44,38 @@ public class H5O_hdr_info_t implements Serializable{ this.mesg_present = mesg_present; this.mesg_shared = mesg_shared; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof H5O_hdr_info_t)) + return false; + + H5O_hdr_info_t info = (H5O_hdr_info_t) o; + + if (this.version != info.version) + return false; + if (this.nmesgs != info.nmesgs) + return false; + if (this.nchunks != info.nchunks) + return false; + if (this.flags != info.flags) + return false; + if (this.space_total != info.space_total) + return false; + if (this.space_meta != info.space_meta) + return false; + if (this.space_mesg != info.space_mesg) + return false; + if (this.space_free != info.space_free) + return false; + if (this.mesg_present != info.mesg_present) + return false; + if (this.mesg_shared != info.mesg_shared) + return false; + + return true; + } } diff --git a/java/src/hdf/hdf5lib/structs/H5O_info_t.java b/java/src/hdf/hdf5lib/structs/H5O_info_t.java index ac32f6a..6a26a10 100644 --- a/java/src/hdf/hdf5lib/structs/H5O_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5O_info_t.java @@ -15,38 +15,30 @@ package hdf.hdf5lib.structs; import java.io.Serializable; -//Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) -public class H5O_info_t implements Serializable{ +// Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) +public class H5O_info_t implements Serializable { private static final long serialVersionUID = 4691681163544054518L; - public long fileno; /* File number that object is located in */ - public long addr; /* Object address in file */ - public int type; /* Basic object type (group, dataset, etc.) */ - public int rc; /* Reference count of object */ - public long atime; /* Access time */ - public long mtime; /* Modification time */ - public long ctime; /* Change time */ - public long btime; /* Birth time */ - public long num_attrs; /* # of attributes attached to object */ - public H5O_hdr_info_t hdr; /* Object header information */ - /* Extra metadata storage for obj & attributes */ - public H5_ih_info_t meta_size_obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ - public H5_ih_info_t meta_size_attr; /* v2 B-tree & heap for attributes */ + public long fileno; /* File number that object is located in */ + public H5O_token_t token; /* Object token in file */ + public int type; /* Basic object type (group, dataset, etc.) */ + public int rc; /* Reference count of object */ + public long atime; /* Access time */ + public long mtime; /* Modification time */ + public long ctime; /* Change time */ + public long btime; /* Birth time */ + public long num_attrs; /* # of attributes attached to object */ - public H5O_info_t (long fileno, long addr, int type, - int rc, long num_attrs, long atime, long mtime, long ctime, long btime, - H5O_hdr_info_t hdr, H5_ih_info_t meta_size_obj, H5_ih_info_t meta_size_attr) + public H5O_info_t (long fileno, H5O_token_t token, int type, + int rc, long atime, long mtime, long ctime, long btime, long num_attrs) { this.fileno = fileno; - this.addr = addr; + this.token = token; this.type = type; this.rc = rc; - this.num_attrs = num_attrs; this.atime = atime; this.mtime = mtime; this.ctime = ctime; this.btime = btime; - this.hdr = hdr; - this.meta_size_obj = meta_size_obj; - this.meta_size_attr = meta_size_attr; + this.num_attrs = num_attrs; } } diff --git a/java/src/hdf/hdf5lib/structs/H5O_native_info_t.java b/java/src/hdf/hdf5lib/structs/H5O_native_info_t.java new file mode 100644 index 0000000..4e80849 --- /dev/null +++ b/java/src/hdf/hdf5lib/structs/H5O_native_info_t.java @@ -0,0 +1,52 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package hdf.hdf5lib.structs; + +import java.io.Serializable; + +// Information struct for native HDF5 object info, such as object header metadata (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx). +public class H5O_native_info_t implements Serializable { + private static final long serialVersionUID = 7883826382952577189L; + + public H5O_hdr_info_t hdr_info; /* Object header information */ + + /* Extra metadata storage for obj & attributes */ + public H5_ih_info_t obj_info; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ + public H5_ih_info_t attr_info; /* v2 B-tree & heap for attributes */ + + H5O_native_info_t (H5O_hdr_info_t oheader_info, H5_ih_info_t obj_info, H5_ih_info_t attr_info) + { + this.hdr_info = oheader_info; + this.obj_info = obj_info; + this.attr_info = attr_info; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof H5O_native_info_t)) + return false; + + H5O_native_info_t info = (H5O_native_info_t) o; + + if (!this.hdr_info.equals(info.hdr_info) + || !this.obj_info.equals(info.obj_info) + || !this.attr_info.equals(info.attr_info)) + return false; + + return true; + } +}
\ No newline at end of file diff --git a/java/src/hdf/hdf5lib/structs/H5O_token_t.java b/java/src/hdf/hdf5lib/structs/H5O_token_t.java new file mode 100644 index 0000000..8ec0b7f --- /dev/null +++ b/java/src/hdf/hdf5lib/structs/H5O_token_t.java @@ -0,0 +1,45 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package hdf.hdf5lib.structs; + +import java.io.Serializable; +import java.util.Arrays; + +import hdf.hdf5lib.HDF5Constants; + +// Object token, which is a unique and permanent identifier, for an HDF5 object within a container. +public class H5O_token_t implements Serializable { + private static final long serialVersionUID = -4754320605310155032L; + public byte[] data; + + H5O_token_t (byte[] data) { + this.data = data; + } + + public boolean isUndefined() { + return this.equals(HDF5Constants.H5O_TOKEN_UNDEF); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof H5O_token_t)) + return false; + + H5O_token_t token = (H5O_token_t) o; + + return Arrays.equals(this.data, token.data); + } +}
\ No newline at end of file diff --git a/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java b/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java index ea36d85..7159f02 100644 --- a/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java @@ -26,4 +26,22 @@ public class H5_ih_info_t implements Serializable { this.index_size = index_size; this.heap_size = heap_size; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof H5_ih_info_t)) + return false; + + H5_ih_info_t info = (H5_ih_info_t) o; + + if (this.index_size != info.index_size) + return false; + if (this.heap_size != info.heap_size) + return false; + + return true; + } } diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c index 0faa0cc..c08b67b 100644 --- a/java/src/jni/exceptionImp.c +++ b/java/src/jni/exceptionImp.c @@ -409,7 +409,7 @@ h5libraryError if (msg_size > 0) { if (NULL == (msg_str = (char *) HDcalloc((size_t)msg_size + 1, sizeof(char)))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5libraryerror: failed to allocate buffer for error message"); + 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) goto done; diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index 05dc2ea..77a5d18 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -684,11 +684,13 @@ Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1TIME(JNIEnv *env, jclass cls) { return JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1NUM_1ATTRS(JNIEnv *env, jclass cls) { return H5O_INFO_NUM_ATTRS; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1HDR(JNIEnv *env, jclass cls) { return H5O_INFO_HDR; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1ALL(JNIEnv *env, jclass cls) { return H5O_INFO_ALL; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1META_1SIZE(JNIEnv *env, jclass cls) { return H5O_INFO_META_SIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1HDR(JNIEnv *env, jclass cls) { return H5O_NATIVE_INFO_HDR; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1ALL(JNIEnv *env, jclass cls) { return H5O_INFO_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1META_1SIZE(JNIEnv *env, jclass cls) { return H5O_NATIVE_INFO_META_SIZE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1ALL(JNIEnv *env, jclass cls) { return H5O_NATIVE_INFO_ALL; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1NONE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_NONE_FLAG; } JNIEXPORT jint JNICALL @@ -713,6 +715,16 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NAMED_1DATATYPE(JNIEnv *env, jclass cls) { return H5O_TYPE_NAMED_DATATYPE; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NTYPES(JNIEnv *env, jclass cls) { return H5O_TYPE_NTYPES; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5O_1MAX_1TOKEN_1SIZE(JNIEnv *env, jclass cls) { return H5O_MAX_TOKEN_SIZE; } +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5O_1TOKEN_1UNDEF(JNIEnv *env, jclass cls) +{ + H5O_token_t undef_token = H5O_TOKEN_UNDEF; + + /* TODO: Can be optimized by keeping a global reference to the undefined token class */ + return create_H5O_token_t(env, &undef_token, FALSE); +} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ROOT(JNIEnv *env, jclass cls){return H5P_ROOT;} diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 85872b2..fb933ad 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -841,10 +841,10 @@ Java_hdf_hdf5lib_H5_H5Aread_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -855,7 +855,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1string if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); @@ -905,7 +905,7 @@ Java_hdf_hdf5lib_H5_H5Awrite_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Awrite_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Awrite_string: memory allocation failed"); for (i = 0; i < (size_t) n; i++) { if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { @@ -1037,7 +1037,7 @@ H5AreadVL_str } if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_str: failed to allocate variable length string read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_str: failed to allocate variable length string read buffer"); if ((status = H5Aread(aid, tid, strs)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1110,7 +1110,7 @@ H5AreadVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (readBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate read buffer"); if ((status = H5Aread(aid, tid, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1119,7 +1119,7 @@ H5AreadVL_asstr h5str_new(&h5str, 4 * typeSize); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate buffer"); /* Convert each element to a char string */ for (i = 0; i < (size_t) n; i++) { @@ -1243,7 +1243,7 @@ H5AwriteVL_str } if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate variable length string write buffer") + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate variable length string write buffer"); for (i = 0; i < size; ++i) { jsize length; @@ -1264,7 +1264,7 @@ H5AwriteVL_str PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5AwriteVL_str: string not pinned"); if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate string buffer"); HDstrncpy(writeBuf[i], utf8, (size_t)length); writeBuf[i][length] = '\0'; @@ -1325,7 +1325,7 @@ H5AwriteVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); /* * When repeatedly writing a dataset with a large number of strs (e.g., 1,000,000 strings), @@ -1406,7 +1406,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref } if (NULL == (ref_data = (H5R_ref_t *) HDcalloc(1, (size_t)n * sizeof(H5R_ref_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer"); if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, ref_data)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1414,7 +1414,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref h5str_new(&h5str, 1024); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate buffer"); for (i = 0; i < n; i++) { h5str.s[0] = '\0'; @@ -1499,7 +1499,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aget_name: failed to allocate attribute name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aget_name: failed to allocate attribute name buffer"); if (H5Aget_name((hid_t)attr_id, (size_t)buf_size + 1, attrName) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1856,7 +1856,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx H5_LIBRARY_ERROR(ENVONLY); if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t) status_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aget_name_by_idx: failed to allocate buffer for attribute name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aget_name_by_idx: failed to allocate buffer for attribute name"); if ((H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t) order, (hsize_t) n, (char *)attrName, (size_t)status_size + 1, (hid_t)lapl_id)) < 0) @@ -2162,7 +2162,7 @@ static herr_t H5A_iterate_cb (hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor, mid; + jmethodID mid; jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jstring str; @@ -2191,18 +2191,7 @@ H5A_iterate_cb args[2].i = info->cset; args[3].j = (jlong)info->data_size; - /* Get a reference to your class if you don't have it already */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5A_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(ZJIJ)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("FATAL ERROR: hdf/hdf5lib/structs/H5A_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 352c047..bcefe12 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -975,10 +975,10 @@ Java_hdf_hdf5lib_H5_H5Dread_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf)) < 0) @@ -990,7 +990,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1string if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); @@ -1041,7 +1041,7 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dwrite_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dwrite_string: memory allocation failed"); for (i = 0; i < (size_t) n; i++) { if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { @@ -1177,7 +1177,7 @@ H5DreadVL_str } if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_str: failed to allocate variable length string read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_str: failed to allocate variable length string read buffer"); if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1263,7 +1263,7 @@ H5DreadVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (readBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate read buffer"); if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1272,7 +1272,7 @@ H5DreadVL_asstr h5str_new(&h5str, 4 * typeSize); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate buffer"); if ((tclass = H5Tget_class(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1442,7 +1442,7 @@ H5DwriteVL_str } if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate variable length string write buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate variable length string write buffer"); for (i = 0; i < size; ++i) { jsize length; @@ -1463,7 +1463,7 @@ H5DwriteVL_str PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5DwriteVL_str: string not pinned"); if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate string buffer"); HDstrncpy(writeBuf[i], utf8, (size_t)length + 1); writeBuf[i][length] = '\0'; @@ -1536,7 +1536,7 @@ H5DwriteVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); for (i = 0; i < (size_t) n; ++i) { if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, (jsize) i))) { @@ -1646,7 +1646,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref } if (NULL == (ref_data = (H5R_ref_t *) HDcalloc(1, (size_t)n * sizeof(H5R_ref_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer"); if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, xfer_plist_id, ref_data)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1654,7 +1654,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref h5str_new(&h5str, 1024); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate buffer"); for (i = 0; i < n; i++) { h5str.s[0] = '\0'; @@ -1909,7 +1909,7 @@ Java_hdf_hdf5lib_H5_H5Dset_1extent PIN_LONG_ARRAY(ENVONLY, buf, dimsBuf, &isCopy, "H5Dset_extent: buffer not pinned"); if (NULL == (dims = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dset_extent: failed to allocate dataset dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dset_extent: failed to allocate dataset dimension buffer"); for (i = 0; i < rank; i++) dims[i] = (hsize_t)dimsBuf[i]; diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c index 937323e..7ea4223 100644 --- a/java/src/jni/h5eImp.c +++ b/java/src/jni/h5eImp.c @@ -309,7 +309,7 @@ Java_hdf_hdf5lib_H5_H5Eget_1class_1name H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: no class name"); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_class_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Eget_class_name: malloc failed"); if ((H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -464,10 +464,10 @@ Java_hdf_hdf5lib_H5_H5Eget_1msg H5_LIBRARY_ERROR(ENVONLY); if (!buf_size) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: invalid message"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: invalid message"); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Eget_msg: malloc failed"); PIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, NULL, "H5Eget_msg: error_msg_type_list not pinned"); @@ -517,7 +517,6 @@ H5E_walk_cb (int nindx, const H5E_error2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor; jmethodID mid; jobject visit_callback = wrapper->visit_callback; jstring str1, str2, str3; @@ -559,16 +558,7 @@ H5E_walk_cb args[6].l = str3; - /* Get a reference to your class if you don't have it already */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, nindx, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 2eb3ad5..3b7b96c 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -131,7 +131,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Fget_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Fget_name: malloc failed"); if ((H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -446,7 +446,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids } if (NULL == (id_list = (hid_t *) HDmalloc((size_t)rank * sizeof(hid_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Fget_obj_ids: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Fget_obj_ids: malloc failed"); if ((ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5iImp.c b/java/src/jni/h5iImp.c index a367802..e8030aee 100644 --- a/java/src/jni/h5iImp.c +++ b/java/src/jni/h5iImp.c @@ -71,7 +71,7 @@ Java_hdf_hdf5lib_H5_H5Iget_1name_1long H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Iget_name_long: buf_size < 0"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Iget_name_long: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Iget_name_long: malloc failed"); if ((size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -111,7 +111,7 @@ Java_hdf_hdf5lib_H5_H5Iget_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Iget_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Iget_name: malloc failed"); if (H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h index 4a94180..f583630 100644 --- a/java/src/jni/h5jni.h +++ b/java/src/jni/h5jni.h @@ -47,195 +47,6 @@ */ #define UNUSED(o) (void) o -/* Macros for class access */ -/* Calling code must define ret_obj as jobject */ -#define CALL_CONSTRUCTOR(env, classname, classsig, args, ret_obj) \ -{ \ - jmethodID constructor; \ - jclass cls; \ - \ - if (NULL == (cls = ENVPTR->FindClass(env, (classname)))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, "JNI error: GetObjectClass"); \ - } \ - if (NULL == (constructor = ENVPTR->GetMethodID(ENVONLY, cls, "<init>", (classsig)))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, "JNI error: GetMethodID failed"); \ - } \ - if (NULL == (ret_obj = ENVPTR->NewObjectA(ENVONLY, cls, constructor, (args)))) { \ - CHECK_JNI_EXCEPTION(env, JNI_FALSE); \ - } \ -} - -/* - * Macros for pinning/unpinning objects. - */ -#define PIN_BYTE_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetByteArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_BYTE_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jbyte *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_BYTE_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseByteArrayElements(env, pinnedArray, (jbyte *) bufToRelease, freeMode); \ -} - -#define PIN_SHORT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetShortArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_SHORT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jshort *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_SHORT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseShortArrayElements(env, pinnedArray, (jshort *) bufToRelease, freeMode); \ -} - -#define PIN_INT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetIntArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_INT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jint *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_INT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseIntArrayElements(env, pinnedArray, (jint *) bufToRelease, freeMode); \ -} - -#define PIN_LONG_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetLongArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_LONG_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jlong *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_LONG_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseLongArrayElements(env, pinnedArray, (jlong *) bufToRelease, freeMode); \ -} - -#define PIN_FLOAT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetFloatArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_FLOAT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jfloat *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_FLOAT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseFloatArrayElements(env, pinnedArray, (jfloat *) bufToRelease, freeMode); \ -} - -#define PIN_DOUBLE_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetDoubleArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_DOUBLE_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jdouble *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_DOUBLE_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseDoubleArrayElements(env, pinnedArray, (jdouble *) bufToRelease, freeMode); \ -} - -#define PIN_BOOL_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetBooleanArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_BOOL_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jboolean *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_BOOL_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseBooleanArrayElements(env, pinnedArray, (jboolean *) bufToRelease, freeMode); \ -} - -#define UNPIN_ARRAY_CRITICAL(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleasePrimitiveArrayCritical(env, pinnedArray, bufToRelease, freeMode); \ -} - -/* Macros for string access */ -#define PIN_JAVA_STRING(env, stringToPin, outString, isCopy, failErrMsg) \ -{ \ - if (NULL == (outString = ENVPTR->GetStringUTFChars(env, stringToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_JAVA_STRING(env, pinnedString, stringToRelease) \ -{ \ - ENVPTR->ReleaseStringUTFChars(env, pinnedString, stringToRelease); \ -} - /* * Macro to check for a JNI exception after a JNI method is called. * If an exception occurred, the value of 'clearException' will determine @@ -246,15 +57,205 @@ * cleanup+return section of the native method, since at that point * cleaning up and returning is the only safe thing that can be done. */ -#define CHECK_JNI_EXCEPTION(env, clearException) \ -{ \ - if (JNI_TRUE == (*env)->ExceptionCheck(env)) { \ - if (JNI_TRUE == clearException) \ - (*env)->ExceptionClear(env); \ - else \ - goto done; \ - } \ -} +#define CHECK_JNI_EXCEPTION(envptr, clearException) \ +do { \ + if (JNI_TRUE == (*envptr)->ExceptionCheck(envptr)) { \ + if (JNI_TRUE == clearException) \ + (*envptr)->ExceptionClear(envptr); \ + else \ + goto done; \ + } \ +} while(0) + +/* Macros for class access */ +/* Calling code must define ret_obj as jobject */ +#define CALL_CONSTRUCTOR(envptr, classname, classsig, args, ret_obj) \ +do { \ + jmethodID constructor; \ + jclass cls; \ + \ + if (NULL == (cls = (*envptr)->FindClass(envptr, (classname)))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, "JNI error: GetObjectClass"); \ + } \ + if (NULL == (constructor = (*envptr)->GetMethodID(envptr, cls, "<init>", (classsig)))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, "JNI error: GetMethodID failed"); \ + } \ + if (NULL == (ret_obj = (*envptr)->NewObjectA(envptr, cls, constructor, (args)))) { \ + HDprintf("FATAL ERROR: %s: Creation failed\n", classname); \ + CHECK_JNI_EXCEPTION(envptr, JNI_FALSE); \ + } \ +} while(0) + +/* + * Macros for pinning/unpinning objects. + */ +#define PIN_BYTE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetByteArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_BYTE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jbyte *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_BYTE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseByteArrayElements(envptr, pinnedArray, (jbyte *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_SHORT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetShortArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_SHORT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jshort *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_SHORT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseShortArrayElements(envptr, pinnedArray, (jshort *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_INT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetIntArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_INT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jint *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_INT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseIntArrayElements(envptr, pinnedArray, (jint *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_LONG_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetLongArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_LONG_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jlong *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_LONG_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseLongArrayElements(envptr, pinnedArray, (jlong *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_FLOAT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetFloatArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_FLOAT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jfloat *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_FLOAT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseFloatArrayElements(envptr, pinnedArray, (jfloat *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_DOUBLE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetDoubleArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_DOUBLE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jdouble *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_DOUBLE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseDoubleArrayElements(envptr, pinnedArray, (jdouble *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_BOOL_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetBooleanArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_BOOL_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jboolean *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_BOOL_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseBooleanArrayElements(envptr, pinnedArray, (jboolean *) bufToRelease, freeMode); \ +} while(0) + +#define UNPIN_ARRAY_CRITICAL(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleasePrimitiveArrayCritical(envptr, pinnedArray, bufToRelease, freeMode); \ +} while(0) + +/* Macros for string access */ +#define PIN_JAVA_STRING(envptr, stringToPin, outString, isCopy, failErrMsg) \ +do { \ + if (NULL == (outString = (*envptr)->GetStringUTFChars(envptr, stringToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_JAVA_STRING(envptr, pinnedString, stringToRelease) \ +do { \ + (*envptr)->ReleaseStringUTFChars(envptr, pinnedString, stringToRelease); \ +} while(0) #ifdef __cplusplus extern "C" { @@ -279,46 +280,46 @@ extern jboolean h5unimplemented( JNIEnv *env, const char *functName); * then do its own error handling, but we instead opt to immediately return. */ #define H5_JNI_FATAL_ERROR(env, message) \ -{ \ +do { \ h5JNIFatalError(env, message); \ goto done; \ -} +} while(0) #define H5_NULL_ARGUMENT_ERROR(env, message) \ -{ \ +do { \ h5nullArgument(env, message); \ goto done; \ -} +} while(0) #define H5_BAD_ARGUMENT_ERROR(env, message) \ -{ \ +do { \ h5badArgument(env, message); \ goto done; \ -} +} while(0) #define H5_OUT_OF_MEMORY_ERROR(env, message) \ -{ \ +do { \ h5outOfMemory(env, message); \ goto done; \ -} +} while(0) #define H5_LIBRARY_ERROR(env) \ -{ \ +do { \ h5libraryError(env); \ goto done; \ -} +} while(0) #define H5_RAISE_EXCEPTION(env, message, exception) \ -{ \ +do { \ h5raiseException(env, message, exception); \ goto done; \ -} +} while(0) #define H5_UNIMPLEMENTED(env, message) \ -{ \ +do { \ h5unimplemented(env, message); \ goto done; \ -} +} while(0) /* implemented at H5.c */ extern jint get_enum_value(JNIEnv *env, jobject enum_obj); @@ -328,6 +329,9 @@ extern jobject get_enum_object(JNIEnv *env, const char* enum_class_name, /* implemented at H5G.c */ extern jobject create_H5G_info_t(JNIEnv *env, H5G_info_t group_info); +/* implemented at h5oimp.c */ +extern jobject create_H5O_token_t(JNIEnv *env, const H5O_token_t *token, hbool_t is_critical_pinning); + #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index 7eee3d4..e60e1ab 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -41,7 +41,7 @@ typedef struct _cb_wrapper { /* Local Prototypes */ /********************/ -static herr_t H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info_t *info, void *cb_data); +static herr_t H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info2_t *info, void *cb_data); /* * Class: hdf_hdf5lib_H5 @@ -281,11 +281,11 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1info (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { - H5L_info_t infobuf; - const char *linkName = NULL; - jvalue args[5]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5L_info2_t infobuf; + const char *linkName = NULL; + jvalue args[5]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -294,16 +294,38 @@ Java_hdf_hdf5lib_H5_H5Lget_1info PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lget_info: link name not pinned"); - if ((status = H5Lget_info((hid_t)loc_id, linkName, &infobuf, (hid_t)access_id)) < 0) + if ((status = H5Lget_info2((hid_t)loc_id, linkName, &infobuf, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - args[0].i = infobuf.type; - args[1].z = infobuf.corder_valid; - args[2].j = infobuf.corder; - args[3].i = infobuf.cset; - args[4].j = (infobuf.type == H5L_TYPE_HARD) ? (jlong) infobuf.u.address : (jlong) infobuf.u.val_size; + /* + * Set the last argument based upon whether this is a hard link (which returns object tokens) + * or a soft/user-defined link (which returns the link's value size). Then, call the appropriate + * constructor to instantiate an H5L_info_t object. + */ + if (infobuf.type == H5L_TYPE_HARD) { + jobject token; + + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(ENVONLY, &infobuf.u.token, FALSE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + args[4].l = token; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, ret_obj); + } + else { + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + args[4].j = (jlong)infobuf.u.val_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, ret_obj); + } done: if (linkName) @@ -322,11 +344,11 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong access_id) { - H5L_info_t infobuf; - const char *groupName = NULL; - jvalue args[5]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5L_info2_t infobuf; + const char *groupName = NULL; + jvalue args[5]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -335,16 +357,38 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_info_by_idx: group name not pinned"); - if ((status = H5Lget_info_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) + if ((status = H5Lget_info_by_idx2((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - args[0].i = infobuf.type; - args[1].z = infobuf.corder_valid; - args[2].j = infobuf.corder; - args[3].i = infobuf.cset; - args[4].j = (infobuf.type == H5L_TYPE_HARD) ? (jlong) infobuf.u.address : (jlong) infobuf.u.val_size; + /* + * Set the last argument based upon whether this is a hard link (which returns object tokens) + * or a soft/user-defined link (which returns the link's value size). Then, call the appropriate + * constructor to instantiate an H5L_info_t object. + */ + if (infobuf.type == H5L_TYPE_HARD) { + jobject token; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, ret_obj); + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(ENVONLY, &infobuf.u.token, FALSE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + args[4].l = token; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, ret_obj); + } + else { + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + args[4].j = (jlong)infobuf.u.val_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, ret_obj); + } done: if (groupName) @@ -381,7 +425,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx /* add extra space for the null terminator */ if (NULL == (linkName = (char *) HDmalloc(sizeof(char) * (size_t)status_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_name_by_idx: failed to allocate buffer for link name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_name_by_idx: failed to allocate buffer for link name"); if ((H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char *)linkName, (size_t)status_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -408,13 +452,13 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jobjectArray link_value, jlong access_id) { - H5L_info_t infobuf; - const char *file_name = NULL; - const char *obj_name = NULL; - const char *linkName = NULL; - jstring str; - herr_t status; - char *linkValue = NULL; + H5L_info2_t infobuf; + const char *file_name = NULL; + const char *obj_name = NULL; + const char *linkName = NULL; + jstring str; + herr_t status; + char *linkValue = NULL; UNUSED(clss); @@ -426,14 +470,14 @@ Java_hdf_hdf5lib_H5_H5Lget_1value PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lget_value: link name not pinned"); /* Get the length of the link value */ - if ((status = H5Lget_info((hid_t)loc_id, linkName, &infobuf, H5P_DEFAULT)) < 0) + if ((status = H5Lget_info2((hid_t)loc_id, linkName, &infobuf, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (H5L_TYPE_HARD == infobuf.type) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: hard links are unsupported"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val: hard links are unsupported"); if (NULL == (linkValue = (char *) HDmalloc(sizeof(char) * infobuf.u.val_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: failed to allocate buffer for link value"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_val: failed to allocate buffer for link value"); if ((status = H5Lget_val((hid_t)loc_id, linkName, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -475,7 +519,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1value case H5L_TYPE_MAX: case H5L_TYPE_HARD: default: - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: invalid link type"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val: invalid link type"); break; } @@ -498,13 +542,13 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jobjectArray link_value, jlong access_id) { - H5L_info_t infobuf; - const char *file_name = NULL; - const char *obj_name = NULL; - const char *grpName = NULL; - jstring str; - herr_t status; - void *linkValue = NULL; + H5L_info2_t infobuf; + const char *file_name = NULL; + const char *obj_name = NULL; + const char *grpName = NULL; + jstring str; + herr_t status; + void *linkValue = NULL; UNUSED(clss); @@ -516,17 +560,17 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lget_val_by_idx: group name not pinned"); /* Get the length of the link value */ - if ((status = H5Lget_info_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) + if ((status = H5Lget_info_by_idx2((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (H5L_TYPE_HARD == infobuf.type) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: hard links are unsupported") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val_by_idx: hard links are unsupported"); if (!infobuf.u.val_size) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (linkValue = (void *) HDmalloc(infobuf.u.val_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: failed to allocate buffer for link value"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_val_by_idx: failed to allocate buffer for link value"); if ((status = H5Lget_val_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -568,7 +612,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx case H5L_TYPE_MAX: case H5L_TYPE_HARD: default: - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: invalid link type"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val_by_idx: invalid link type"); break; } @@ -615,12 +659,15 @@ done: UNPIN_JAVA_STRING(ENVONLY, cur_name, lCurName); } /* end Java_hdf_hdf5lib_H5_H5Lmove */ +/* + * Shim function for link iteration and link visiting which + */ static herr_t H5L_iterate_cb - (hid_t g_id, const char *name, const H5L_info_t *info, void *cb_data) + (hid_t g_id, const char *name, const H5L_info2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor, mid; + jmethodID mid; jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jstring str; @@ -635,32 +682,44 @@ H5L_iterate_cb H5_JNI_FATAL_ERROR(CBENVONLY, "H5L_iterate_cb: failed to attach current thread to JVM"); } + /* Get the Method ID for the "callback" function of the H5L_iterate_t class */ if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_opdata_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - args[0].i = info->type; - args[1].z = info->corder_valid; - args[2].j = info->corder; - args[3].i = info->cset; - args[4].j = (info->type == H5L_TYPE_HARD) ? (jlong)info->u.address : (jlong)info->u.val_size; - - /* Get a reference to your class if you don't have it already */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(IZJIJ)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("FATAL ERROR: hdf/hdf5lib/structs/H5L_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + /* + * Set the last argument based upon whether this is a hard link (which returns object tokens) + * or a soft/user-defined link (which returns the link's value size). Then, call the appropriate + * constructor to instantiate an H5L_info_t object. + */ + if (info->type == H5L_TYPE_HARD) { + jobject token; + + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(CBENVONLY, &info->u.token, FALSE))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[0].i = info->type; + args[1].z = info->corder_valid; + args[2].j = info->corder; + args[3].i = info->cset; + args[4].l = token; + + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, cb_info_t); + } + else { + args[0].i = info->type; + args[1].z = info->corder_valid; + args[2].j = info->corder; + args[3].i = info->cset; + args[4].j = (jlong)info->u.val_size; + + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, cb_info_t); } status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); @@ -696,7 +755,8 @@ Java_hdf_hdf5lib_H5_H5Lvisit if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit: callback_op is NULL"); - if ((status = H5Lvisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void *)&wrapper)) < 0) + if ((status = H5Lvisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, + H5L_iterate_cb, (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -731,7 +791,8 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lvisit_by_name: group name not pinned"); - if ((status = H5Lvisit_by_name((hid_t)grp_id, grpName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void *)&wrapper, (hid_t)access_id)) < 0) + if ((status = H5Lvisit_by_name2((hid_t)grp_id, grpName, (H5_index_t)idx_type, (H5_iter_order_t)order, + H5L_iterate_cb, (void *)&wrapper, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -765,7 +826,8 @@ Java_hdf_hdf5lib_H5_H5Literate if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate: callback_op is NULL"); - if ((status = H5Literate((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t *)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void *)&wrapper)) < 0) + if ((status = H5Literate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, + &start_idx, H5L_iterate_cb, (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -801,7 +863,8 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Literate_by_name: group name not pinned"); - if ((status = H5Literate_by_name((hid_t)grp_id, groupName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id)) < 0) + if ((status = H5Literate_by_name2((hid_t)grp_id, groupName, (H5_index_t)idx_type, (H5_iter_order_t)order, + &start_idx, H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c index b49a3e9..1d828a1 100644 --- a/java/src/jni/h5oImp.c +++ b/java/src/jni/h5oImp.c @@ -40,7 +40,58 @@ typedef struct _cb_wrapper { /* Local Prototypes */ /********************/ -static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data); +static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info2_t *info, void *cb_data); + +/* + * Create a java object of hdf.hdf5lib.structs.H5O_token_t. + */ +jobject +create_H5O_token_t + (JNIEnv *envptr, const H5O_token_t *token, hbool_t is_critical_pinning) +{ + jbyteArray tokenByteBuf; + jboolean token_buf_is_copy; + jvalue constructor_args[1]; + jbyte *token_buf = NULL; + jobject ret_token_obj = NULL; + + if (NULL == (tokenByteBuf = (*envptr)->NewByteArray(envptr, H5O_MAX_TOKEN_SIZE))) + CHECK_JNI_EXCEPTION(envptr, JNI_FALSE); + + if (is_critical_pinning) + PIN_BYTE_ARRAY_CRITICAL(envptr, tokenByteBuf, token_buf, &token_buf_is_copy, "create_H5O_token_t: object token buffer not pinned"); + else + PIN_BYTE_ARRAY(envptr, tokenByteBuf, token_buf, &token_buf_is_copy, "create_H5O_token_t: object token buffer not pinned"); + + HDmemcpy(token_buf, token, sizeof(H5O_token_t)); + + if (is_critical_pinning) + UNPIN_ARRAY_CRITICAL(envptr, tokenByteBuf, token_buf, 0); + else + UNPIN_BYTE_ARRAY(envptr, tokenByteBuf, token_buf, 0); + + token_buf = NULL; + + constructor_args[0].l = tokenByteBuf; + CALL_CONSTRUCTOR(envptr, "hdf/hdf5lib/structs/H5O_token_t", "([B)V", constructor_args, ret_token_obj); + + /* + * If critical pinning is being used, this routine is probably being + * called within a loop, so we'll clean up local references. + */ + if (is_critical_pinning) + (*envptr)->DeleteLocalRef(envptr, tokenByteBuf); + +done: + if (token_buf) { + if (is_critical_pinning) + UNPIN_ARRAY_CRITICAL(envptr, tokenByteBuf, token_buf, JNI_ABORT); + else + UNPIN_BYTE_ARRAY(envptr, tokenByteBuf, token_buf, JNI_ABORT); + } /* end if */ + + return ret_token_obj; +} /* end create_H5O_token_t */ /* * Class: hdf_hdf5lib_H5 @@ -134,17 +185,156 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info (JNIEnv *env, jclass clss, jlong loc_id, jint fields) { - H5O_info_t infobuf; - jobject hdrinfobuf; - jobject ihinfobuf1; - jobject ihinfobuf2; - jvalue args[12]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_info2_t infobuf; + jobject token; + jvalue args[9]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + if ((status = H5Oget_info3((hid_t)loc_id, &infobuf, (unsigned)fields)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (token = create_H5O_token_t(ENVONLY, &infobuf.token, FALSE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + args[0].j = (jlong)infobuf.fileno; + args[1].l = token; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = infobuf.atime; + args[5].j = infobuf.mtime; + args[6].j = infobuf.ctime; + args[7].j = infobuf.btime; + args[8].j = (jlong)infobuf.num_attrs; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); + +done: + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info_by_name + * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name + (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, jlong access_id) +{ + H5O_info2_t infobuf; + const char *objName = NULL; + jobject token; + jvalue args[9]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); - if ((status = H5Oget_info2((hid_t)loc_id, &infobuf, (unsigned)fields)) < 0) + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_info_by_name: object name is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_info_by_name: object name not pinned"); + + if ((status = H5Oget_info_by_name3((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(ENVONLY, &infobuf.token, FALSE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + args[0].j = (jlong)infobuf.fileno; + args[1].l = token; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = infobuf.atime; + args[5].j = infobuf.mtime; + args[6].j = infobuf.ctime; + args[7].j = infobuf.btime; + args[8].j = (jlong)infobuf.num_attrs; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); + + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info_by_idx + * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx + (JNIEnv *env, jclass clss, jlong loc_id, + jstring name, jint index_field, jint order, jlong link_n, jint fields, jlong access_id) +{ + H5O_info2_t infobuf; + const char *grpName = NULL; + jobject token; + jvalue args[9]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_info_by_idx: group name is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_info_by_idx: group name not pinned"); + + if ((status = H5Oget_info_by_idx3((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, + &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(ENVONLY, &infobuf.token, FALSE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + args[0].j = (jlong)infobuf.fileno; + args[1].l = token; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = infobuf.atime; + args[5].j = infobuf.mtime; + args[6].j = infobuf.ctime; + args[7].j = infobuf.btime; + args[8].j = (jlong)infobuf.num_attrs; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); + +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); + + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_native_info + * Signature: (JI)Lhdf/hdf5lib/structs/H5O_native_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1native_1info + (JNIEnv *env, jclass clss, jlong loc_id, jint fields) +{ + H5O_native_info_t infobuf; + jobject hdrinfobuf; + jobject obj_ihinfobuf; + jobject attr_ihinfobuf; + jvalue args[10]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + if ((status = H5Oget_native_info((hid_t)loc_id, &infobuf, (unsigned)fields)) < 0) H5_LIBRARY_ERROR(ENVONLY); args[0].i = (jint)infobuf.hdr.version; @@ -165,59 +355,50 @@ Java_hdf_hdf5lib_H5_H5Oget_1info args[1].j = (jlong)infobuf.meta_size.obj.heap_size; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); - ihinfobuf1 = ret_obj; + obj_ihinfobuf = ret_obj; args[0].j = (jlong)infobuf.meta_size.attr.index_size; args[1].j = (jlong)infobuf.meta_size.attr.heap_size; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); - ihinfobuf2 = ret_obj; + attr_ihinfobuf = ret_obj; - args[0].j = (jlong)infobuf.fileno; - args[1].j = (jlong)infobuf.addr; - args[2].i = infobuf.type; - args[3].i = (jint)infobuf.rc; - args[4].j = (jlong)infobuf.num_attrs; - args[5].j = infobuf.atime; - args[6].j = infobuf.mtime; - args[7].j = infobuf.ctime; - args[8].j = infobuf.btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; + args[0].l = hdrinfobuf; + args[1].l = obj_ihinfobuf; + args[2].l = attr_ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); done: return ret_obj; -} /* end Java_hdf_hdf5lib_H5_H5Oget_1info */ +} /* end Java_hdf_hdf5lib_H5_H5Oget_1native_1info */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Oget_info_by_name - * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_info_t; + * Method: H5Oget_native_info_by_name + * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_native_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name +Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, jlong access_id) { - H5O_info_t infobuf; - const char *objName = NULL; - jobject hdrinfobuf; - jobject ihinfobuf1; - jobject ihinfobuf2; - jvalue args[12]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_native_info_t infobuf; + const char *objName = NULL; + jobject hdrinfobuf; + jobject obj_ihinfobuf; + jobject attr_ihinfobuf; + jvalue args[10]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); if (NULL == name) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_info_by_name: object name is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_native_info_by_name: object name is NULL"); - PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_info_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_native_info_by_name: object name not pinned"); - if ((status = H5Oget_info_by_name2((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = H5Oget_native_info_by_name((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); args[0].i = (jint)infobuf.hdr.version; @@ -238,63 +419,55 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name args[1].j = (jlong)infobuf.meta_size.obj.heap_size; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); - ihinfobuf1 = ret_obj; + obj_ihinfobuf = ret_obj; args[0].j = (jlong)infobuf.meta_size.attr.index_size; args[1].j = (jlong)infobuf.meta_size.attr.heap_size; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); - ihinfobuf2 = ret_obj; + attr_ihinfobuf = ret_obj; - args[0].j = (jlong)infobuf.fileno; - args[1].j = (jlong)infobuf.addr; - args[2].i = infobuf.type; - args[3].i = (jint)infobuf.rc; - args[4].j = (jlong)infobuf.num_attrs; - args[5].j = infobuf.atime; - args[6].j = infobuf.mtime; - args[7].j = infobuf.ctime; - args[8].j = infobuf.btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; + args[0].l = hdrinfobuf; + args[1].l = obj_ihinfobuf; + args[2].l = attr_ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); done: if (objName) UNPIN_JAVA_STRING(ENVONLY, name, objName); return ret_obj; -} /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name */ +} /* end Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Oget_info_by_idx - * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_info_t; + * Method: H5Oget_native_info_by_idx + * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_native_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx +Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jint fields, jlong access_id) { - H5O_info_t infobuf; - const char *grpName = NULL; - jobject hdrinfobuf; - jobject ihinfobuf1; - jobject ihinfobuf2; - jvalue args[12]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_native_info_t infobuf; + const char *grpName = NULL; + jobject hdrinfobuf; + jobject obj_ihinfobuf; + jobject attr_ihinfobuf; + jvalue args[10]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); if (NULL == name) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_info_by_idx: group name is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_native_info_by_idx: group name is NULL"); - PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_info_by_idx: group name not pinned"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_native_info_by_idx: group name not pinned"); - if ((status = H5Oget_info_by_idx2((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = H5Oget_native_info_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, + &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); args[0].i = (jint)infobuf.hdr.version; @@ -315,35 +488,26 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx args[1].j = (jlong)infobuf.meta_size.obj.heap_size; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); - ihinfobuf1 = ret_obj; + obj_ihinfobuf = ret_obj; args[0].j = (jlong)infobuf.meta_size.attr.index_size; args[1].j = (jlong)infobuf.meta_size.attr.heap_size; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); - ihinfobuf2 = ret_obj; + attr_ihinfobuf = ret_obj; - args[0].j = (jlong)infobuf.fileno; - args[1].j = (jlong)infobuf.addr; - args[2].i = infobuf.type; - args[3].i = (jint)infobuf.rc; - args[4].j = (jlong)infobuf.num_attrs; - args[5].j = infobuf.atime; - args[6].j = infobuf.mtime; - args[7].j = infobuf.ctime; - args[8].j = infobuf.btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; + args[0].l = hdrinfobuf; + args[1].l = obj_ihinfobuf; + args[2].l = attr_ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); done: if (grpName) UNPIN_JAVA_STRING(ENVONLY, name, grpName); return ret_obj; -} /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx */ +} /* end Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx */ /* * Class: hdf_hdf5lib_H5 @@ -375,15 +539,13 @@ done: static herr_t H5O_iterate_cb - (hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data) + (hid_t g_id, const char *name, const H5O_info2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor, mid; + jmethodID mid; jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; - jobject hdrinfobuf; - jobject ihinfobuf1; - jobject ihinfobuf2; + jobject token; jstring str; JNIEnv *cbenv = NULL; jclass cls; @@ -399,85 +561,28 @@ H5O_iterate_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_opdata_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - args[0].i = (jint)info->hdr.version; - args[1].i = (jint)info->hdr.nmesgs; - args[2].i = (jint)info->hdr.nchunks; - args[3].i = (jint)info->hdr.flags; - args[4].j = (jlong)info->hdr.space.total; - args[5].j = (jlong)info->hdr.space.meta; - args[6].j = (jlong)info->hdr.space.mesg; - args[7].j = (jlong)info->hdr.space.free; - args[8].j = (jlong)info->hdr.mesg.present; - args[9].j = (jlong)info->hdr.mesg.shared; - - /* Get a reference to the H5_hdr_info_t class */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(IIIIJJJJJJ)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (hdrinfobuf = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_hdr_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } - - args[0].j = (jlong)info->meta_size.obj.index_size; - args[1].j = (jlong)info->meta_size.obj.heap_size; - - /* Get a reference to the H5_ih_info_t class */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJ)V"))) + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(CBENVONLY, &info->token, FALSE))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (ihinfobuf1 = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } - - args[0].j = (jlong)info->meta_size.attr.index_size; - args[1].j = (jlong)info->meta_size.attr.heap_size; - - if (NULL == (ihinfobuf2 = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } - args[0].j = (jlong)info->fileno; - args[1].j = (jlong)info->addr; + args[1].l = token; args[2].i = info->type; args[3].i = (jint)info->rc; - args[4].j = (jlong)info->num_attrs; - args[5].j = info->atime; - args[6].j = info->mtime; - args[7].j = info->ctime; - args[8].j = info->btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; + args[4].j = info->atime; + args[5].j = info->mtime; + args[6].j = info->ctime; + args[7].j = info->btime; + args[8].j = (jlong)info->num_attrs; /* Get a reference to the H5O_info_t class */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); @@ -512,7 +617,8 @@ Java_hdf_hdf5lib_H5_H5Ovisit if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit: callback_op is NULL"); - if ((status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void *)&wrapper, (unsigned)fields)) < 0) + if ((status = H5Ovisit3((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, + H5O_iterate_cb, (void *)&wrapper, (unsigned)fields)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -547,7 +653,8 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Ovisit_by_name: object name not pinned"); - if ((status = H5Ovisit_by_name2((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void *)&wrapper, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = H5Ovisit_by_name3((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, + H5O_iterate_cb, (void *)&wrapper, (unsigned)fields, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -639,7 +746,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment if (buf_size) { if (NULL == (oComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer"); if ((status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -684,7 +791,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name if (buf_size) { if (NULL == (objComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment"); if ((status = H5Oget_comment_by_name((hid_t)loc_id, objName, objComment, (size_t)buf_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -772,23 +879,46 @@ done: /* * Class: hdf_hdf5lib_H5 - * Method: _H5Oopen_by_addr - * Signature: (JJ)J; + * Method: _H5Oopen_by_token + * Signature: (JLhdf/hdf5lib/structs/H5O_token_t;)J; */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr - (JNIEnv *env, jclass clss, jlong loc_id, jlong addr) +Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token + (JNIEnv *env, jclass clss, jlong loc_id, jobject token) { - hid_t retVal = H5I_INVALID_HID; + H5O_token_t obj_token; + jboolean token_buf_is_copy; + jfieldID token_data_field_id; + jclass token_cls; + jbyte *token_buf = NULL; + jobject token_data; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Oopen_by_addr((hid_t)loc_id, (haddr_t)addr)) < 0) + token_cls = ENVPTR->GetObjectClass(ENVONLY, token); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (token_data_field_id = ENVPTR->GetFieldID(ENVONLY, token_cls, "data", "[B"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + token_data = ENVPTR->GetObjectField(ENVONLY, token, token_data_field_id); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, (jbyteArray)token_data, token_buf, &token_buf_is_copy, "H5Oopen_by_token: token buffer not pinned"); + HDmemcpy(&obj_token, token_buf, sizeof(H5O_token_t)); + UNPIN_BYTE_ARRAY(ENVONLY, (jbyteArray)token_data, token_buf, JNI_ABORT); + token_buf = NULL; + + if ((retVal = H5Oopen_by_token((hid_t)loc_id, obj_token)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: + if (token_buf) + UNPIN_BYTE_ARRAY(ENVONLY, (jbyteArray)token_data, token_buf, (retVal < 0) ? JNI_ABORT : 0); + return (jlong)retVal; -} /* end Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr */ +} /* end Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token */ /* * Class: hdf_hdf5lib_H5 diff --git a/java/src/jni/h5oImp.h b/java/src/jni/h5oImp.h index 5241aba..2b53fd3 100644 --- a/java/src/jni/h5oImp.h +++ b/java/src/jni/h5oImp.h @@ -78,6 +78,33 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx /* * Class: hdf_hdf5lib_H5 + * Method: H5Oget_native_info + * Signature: (JI)Lhdf/hdf5lib/structs/H5O_native_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1native_1info +(JNIEnv*, jclass, jlong, jint fields); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_native_info_by_name + * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_native_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name +(JNIEnv*, jclass, jlong, jstring, jint fields, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_native_info_by_idx + * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_native_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx +(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jint fields, jlong); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Olink * Signature: (JJLjava/lang/String;JJ)V */ @@ -168,12 +195,12 @@ Java_hdf_hdf5lib_H5_H5Oincr_1refcount /* * Class: hdf_hdf5lib_H5 - * Method: _H5Oopen_by_addr - * Signature: (JJ)J; + * Method: _H5Oopen_by_token + * Signature: (JLhdf/hdf5lib/structs/H5O_token_t;)J; */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr - (JNIEnv*, jclass, jlong, jlong); +Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token + (JNIEnv*, jclass, jlong, jobject); /* * Class: hdf_hdf5lib_H5 diff --git a/java/src/jni/h5pDAPLImp.c b/java/src/jni/h5pDAPLImp.c index fb39b84..2386df1 100644 --- a/java/src/jni/h5pDAPLImp.c +++ b/java/src/jni/h5pDAPLImp.c @@ -151,7 +151,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix H5_LIBRARY_ERROR(ENVONLY); if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_efile_prefix: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_efile_prefix: memory allocation failed"); if (H5Pget_efile_prefix((hid_t)dapl_id, (char *)pre, (size_t)prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -159,7 +159,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pDCPLImp.c b/java/src/jni/h5pDCPLImp.c index 7559c3b..c43079f 100644 --- a/java/src/jni/h5pDCPLImp.c +++ b/java/src/jni/h5pDCPLImp.c @@ -109,7 +109,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1chunk PIN_BYTE_ARRAY(ENVONLY, dim, theArray, &isCopy, "H5Pset_chunk: dim array not pinned"); if (NULL == (da = lp = (hsize_t *) HDmalloc(rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); jlp = (jlong *)theArray; for (i = 0; i < rank; i++) { @@ -161,7 +161,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1chunk PIN_LONG_ARRAY(ENVONLY, dims, theArray, &isCopy, "H5Pget_chunk: input dims not pinned"); if (NULL == (da = (hsize_t *) HDmalloc((size_t)max_ndims * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_chunk: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_chunk: memory allocation failed"); if ((status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -595,7 +595,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: cd_values is NULL"); if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter: flags array not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter: nelmts array not pinned"); @@ -620,7 +620,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -632,7 +632,7 @@ done: if (cd_nelmtsArray) UNPIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, (status < 0) ? JNI_ABORT : 0); if (flagsArray) - UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0) + UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0); if (filter) HDfree(filter); @@ -671,7 +671,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: filter_config is NULL"); if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter2: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter2: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter2: flags array not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter2: nelmts array not pinned"); @@ -715,7 +715,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -772,7 +772,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: name is NULL"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id: flags not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id: cd_nelms not pinned"); @@ -801,7 +801,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -858,7 +858,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: filter_config is NULL"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id2: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id2: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id2: flags not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id2: cd_nelms not pinned"); @@ -882,7 +882,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -1122,7 +1122,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1external if (name_size > 0) if (NULL == (file = (char *) HDmalloc(sizeof(char) * (size_t)name_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_external: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_external: memory allocation failed"); if ((status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size, file, (off_t *)&o, (hsize_t *)&s)) < 0) @@ -1140,7 +1140,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1external if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, file))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -1250,7 +1250,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname H5_LIBRARY_ERROR(ENVONLY); if (NULL == (dname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_dsetname: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_dsetname: memory allocation failed"); if (H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, dname, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1258,7 +1258,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, dname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); } done: @@ -1288,7 +1288,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename H5_LIBRARY_ERROR(ENVONLY); if (NULL == (fname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_filename: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_filename: memory allocation failed"); if (H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, fname, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1296,7 +1296,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, fname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); } done: @@ -1392,7 +1392,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix H5_LIBRARY_ERROR(ENVONLY); if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_prefix: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_prefix: memory allocation failed"); if (H5Pget_virtual_prefix((hid_t)dapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1400,7 +1400,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pDXPLImp.c b/java/src/jni/h5pDXPLImp.c index 323fa8c..12e3367 100644 --- a/java/src/jni/h5pDXPLImp.c +++ b/java/src/jni/h5pDXPLImp.c @@ -310,7 +310,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform H5_LIBRARY_ERROR(ENVONLY); if (NULL == (express = (char *) HDmalloc(sizeof(char) * (size_t)express_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_data_transform: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_data_transform: memory allocation failed"); if (H5Pget_data_transform((hid_t)plist_id, express, (size_t)express_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -318,7 +318,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, express))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, expression, 0, str); diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c index a627e65..c9844b7 100644 --- a/java/src/jni/h5pFAPLImp.c +++ b/java/src/jni/h5pFAPLImp.c @@ -308,7 +308,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family } if (NULL == (sa = (hsize_t *) HDmalloc((size_t) rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_family: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_family: memory allocation failed"); PIN_LONG_ARRAY(ENVONLY, memb_plist, plistArray, &isCopy, "H5Pget_family: plistArray not pinned"); @@ -398,7 +398,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs if (NULL != fa.namenode_name) { if (NULL == (j_namenode_name = ENVPTR->NewStringUTF(ENVONLY, fa.namenode_name))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create namenode_name string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create namenode_name string"); } } args[0].l = j_namenode_name; @@ -408,7 +408,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs if (NULL != fa.user_name) { if (NULL == (j_user_name = ENVPTR->NewStringUTF(ENVONLY, fa.user_name))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create user_name string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create user_name string"); } } args[2].l = j_user_name; @@ -416,7 +416,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs if (NULL != fa.kerberos_ticket_cache) { if (NULL == (j_kerb_cache_path = ENVPTR->NewStringUTF(ENVONLY, fa.kerberos_ticket_cache))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create kerberos_ticket_cache string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create kerberos_ticket_cache string"); } } args[3].l = j_kerb_cache_path; @@ -651,7 +651,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi str_len = HDstrlen(utf8); if (NULL == (member_name[i] = (char *) HDmalloc(str_len + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); HDstrncpy(member_name[i], utf8, str_len + 1); (member_name[i])[str_len] = '\0'; @@ -678,7 +678,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi if (NULL == (rstring = ENVPTR->NewStringUTF(ENVONLY, member_name[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); } if (NULL == (o = ENVPTR->GetObjectArrayElement(ENVONLY, memb_name, (jsize) i))) { @@ -750,7 +750,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pget_fapl_multi: memb_addr not pinned"); if (memb_name) if (NULL == (mName = (char **) HDcalloc(H5FD_MEM_NTYPES, sizeof(*mName)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_multi: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_multi: memory allocation failed"); if ((status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t *)themapArray, (hid_t *)thefaplArray, mName, (haddr_t *)theaddrArray, (hbool_t *)&relax)) < 0) @@ -761,7 +761,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi if (mName[i]) { if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, mName[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize) i, (jobject)str); @@ -823,7 +823,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 if (NULL != fa.aws_region) { if (NULL == (j_aws = ENVPTR->NewStringUTF(ENVONLY, fa.aws_region))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create aws_region string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create aws_region string"); } } args[0].l = j_aws; @@ -831,7 +831,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 if (NULL != fa.secret_id) { if (NULL == (j_id = ENVPTR->NewStringUTF(ENVONLY, fa.secret_id))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_id string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_id string"); } } args[1].l = j_id; @@ -839,7 +839,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 if (NULL != fa.secret_key) { if (NULL == (j_key = ENVPTR->NewStringUTF(ENVONLY, fa.secret_key))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_key string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_key string"); } } args[2].l = j_key; @@ -1688,7 +1688,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config if (NULL != cacheinfo.trace_file_name) { if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, cacheinfo.trace_file_name))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); } } @@ -1802,7 +1802,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options location_size++; /* add extra space for the null terminator */ if (NULL == (lname = (char *) HDmalloc(sizeof(char) * location_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_log_options: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_log_options: memory allocation failed"); if ((status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, &start_on_access)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1810,7 +1810,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, lname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); } mdc_log_options_ptr[0] = (jboolean)is_enabled; diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index 726e08c..9e5b004 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -503,7 +503,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1class_1name if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, c_str))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pLAPLImp.c b/java/src/jni/h5pLAPLImp.c index f2cb80a..754bece 100644 --- a/java/src/jni/h5pLAPLImp.c +++ b/java/src/jni/h5pLAPLImp.c @@ -134,7 +134,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix H5_LIBRARY_ERROR(ENVONLY); if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_elink_prefix: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_elink_prefix: memory allocation failed"); if (H5Pget_elink_prefix((hid_t)lapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -142,7 +142,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, prefix, 0, str); diff --git a/java/src/jni/h5plImp.c b/java/src/jni/h5plImp.c index 90d78fe..b43b532 100644 --- a/java/src/jni/h5plImp.c +++ b/java/src/jni/h5plImp.c @@ -226,7 +226,7 @@ Java_hdf_hdf5lib_H5_H5PLget H5_LIBRARY_ERROR(ENVONLY); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5PLget: failed to allocate plugin name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5PLget: failed to allocate plugin name buffer"); if ((H5PLget((unsigned) index, aName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index 21ee658..def27f4 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -51,7 +51,7 @@ Java_hdf_hdf5lib_H5_H5Rcreate_1object PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate_object: reference name not pinned"); if (NULL == (refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_object: failed to allocate reference buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rcreate_object: failed to allocate reference buffer"); if ((status = H5Rcreate_object((hid_t)loc_id, refName, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -94,7 +94,7 @@ Java_hdf_hdf5lib_H5_H5Rcreate_1region PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate_region: reference name not pinned"); if (NULL == (refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_region: failed to allocate reference buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rcreate_region: failed to allocate reference buffer"); if ((status = H5Rcreate_region((hid_t)loc_id, refName, space_id, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -141,7 +141,7 @@ Java_hdf_hdf5lib_H5_H5Rcreate_1attr PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate_attr: reference name not pinned"); if (NULL == (refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate reference buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate reference buffer"); if ((status = H5Rcreate_attr((hid_t)loc_id, refName, attrName, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -315,7 +315,7 @@ Java_hdf_hdf5lib_H5_H5Rcopy PIN_BYTE_ARRAY(ENVONLY, src_ref, src_refBuf, &isCopy, "H5Rcopy: src reference buffer not pinned"); if (NULL == (dst_refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate dst reference buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate dst reference buffer"); if ((status = H5Rcopy((const H5R_ref_t *)src_refBuf, (const H5R_ref_t *)dst_refBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -505,7 +505,7 @@ Java_hdf_hdf5lib_H5_H5Rget_1file_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_file_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_file_name: malloc failed"); if ((check_size = H5Rget_file_name((const H5R_ref_t *)refBuf, namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -551,7 +551,7 @@ Java_hdf_hdf5lib_H5_H5Rget_1obj_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_obj_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_obj_name: malloc failed"); if ((check_size = H5Rget_obj_name((const H5R_ref_t *)refBuf, (hid_t)rapl_id, namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -597,7 +597,7 @@ Java_hdf_hdf5lib_H5_H5Rget_1attr_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_attr_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_attr_name: malloc failed"); if ((check_size = H5Rget_attr_name((const H5R_ref_t *)refBuf, namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -645,9 +645,9 @@ Java_hdf_hdf5lib_H5_H5Rcreate } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference input array length != H5R_OBJ_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: unknown reference type"); @@ -692,9 +692,9 @@ Java_hdf_hdf5lib_H5__1H5Rdereference } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: unknown reference type"); @@ -854,16 +854,16 @@ Java_hdf_hdf5lib_H5_H5Rget_1name } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference input array length != H5R_OBJ_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: unknown reference type"); PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_name: reference buffer not pinned"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_name: failed to allocate referenced object name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_name: failed to allocate referenced object name buffer"); if ((ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, aName, (size_t)size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index c703e90..74866ed 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -98,7 +98,7 @@ Java_hdf_hdf5lib_H5__1H5Screate_1simple PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Screate_simple: dims not pinned"); if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Screate_simple: failed to allocate dims buffer") + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Screate_simple: failed to allocate dims buffer"); jlp = (jlong *) dimsP; for (i = 0; i < rank; i++) { @@ -115,7 +115,7 @@ Java_hdf_hdf5lib_H5__1H5Screate_1simple PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Screate_simple: maxdims not pinned"); if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Screate_simple: failed to allocate maxdims buffer") + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Screate_simple: failed to allocate maxdims buffer"); jlp = (jlong *) maxdimsP; for (i = 0; i < mrank; i++) { @@ -194,7 +194,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements PIN_LONG_ARRAY(ENVONLY, coords, P, &isCopy, "H5Sselect_elements: coords not pinned"); if (NULL == (sa = (hssize_t *) HDmalloc( (size_t)num_elemn * 2 * sizeof(hssize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); for (i = 0; i < (num_elemn * 2); i++) { sa[i] = P[i]; @@ -247,7 +247,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements nlongs = (int)((size_t)size / sizeof(jlong)); if (NULL == (lp = (hsize_t *) HDmalloc((size_t)nlongs * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); jlp = (jlong *) P; llp = lp; @@ -444,7 +444,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims } if (NULL == (sa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate dimension buffer"); } if (NULL == maxdims) { @@ -462,10 +462,10 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims if (rank < 0) rank = mrank; else if (mrank != rank) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); if (NULL == (msa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); } if ((status = H5Sget_simple_extent_dims(space_id, (hsize_t *)sa, (hsize_t *)msa)) < 0) @@ -564,7 +564,7 @@ Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Sset_extent_simple: dims not pinned"); if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate dimension buffer"); jlp = (jlong *) dimsP; for (i = 0; i < rank; i++) { @@ -581,7 +581,7 @@ Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Sset_extent_simple: maxdims not pinned"); if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); jlp = (jlong *) maxdimsP; for (i = 0; i < rank; i++) { @@ -660,7 +660,7 @@ Java_hdf_hdf5lib_H5_H5Soffset_1simple rank = (size_t) i / sizeof(jlong); if (NULL == (sa = lp = (hssize_t *) HDmalloc((size_t)rank * sizeof(hssize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); jlp = (jlong *) P; for (i = 0; (size_t) i < rank; i++) { @@ -788,7 +788,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sselect_hyperslab: start not pinned"); if (NULL == (strt = lp = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate start buffer"); jlp = (jlong *) startP; for (i = 0; i < start_rank; i++) { @@ -800,7 +800,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sselect_hyperslab: count not pinned"); if (NULL == (cnt = lp = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate count buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate count buffer"); jlp = (jlong *) countP; for (i = 0; i < count_rank; i++) { @@ -825,7 +825,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sselect_hyperslab: stride not pinned"); if (NULL == (strd = lp = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate stride buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate stride buffer"); jlp = (jlong *) strideP; for (i = 0; i < stride_rank; i++) { @@ -851,7 +851,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sselect_hyperslab: block not pinned"); if (NULL == (blk = lp = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate block buffer"); jlp = (jlong *) blockP; for (i = 0; i < block_rank; i++) { @@ -988,7 +988,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist buf_size = (size_t) numblocks * (size_t) 2 * (size_t) rank * sizeof(hsize_t); if (NULL == (ba = (hsize_t *) HDmalloc(buf_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); if ((status = H5Sget_select_hyper_blocklist((hid_t)spaceid, (hsize_t) startblock, (hsize_t) numblocks, (hsize_t *)ba)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1044,7 +1044,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist PIN_LONG_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sget_select_elem_pointlist: buffer not pinned"); if (NULL == (ba = (hsize_t *) HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: failed to allocate point list buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: failed to allocate point list buffer"); if ((status = H5Sget_select_elem_pointlist((hid_t)spaceid, (hsize_t)startpoint, (hsize_t)numpoints, (hsize_t *)ba)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1094,12 +1094,12 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds } if (NULL == (strt = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate start buffer"); PIN_LONG_ARRAY(ENVONLY, end, endP, &isCopy, "H5Sget_select_bounds: end not pinned"); if (NULL == (en = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate end buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate end buffer"); if ((status = H5Sget_select_bounds((hid_t) spaceid, (hsize_t *) strt, (hsize_t *) en)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1148,7 +1148,7 @@ Java_hdf_hdf5lib_H5_H5Sencode H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: buf_size = 0"); if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); if ((status = H5Sencode2((hid_t) obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1258,7 +1258,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sget_regular_hyperslab: start not pinned"); if (NULL == (strt = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate start buffer"); } if (NULL == stride) { @@ -1277,7 +1277,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sget_regular_hyperslab: stride not pinned"); if (NULL == (strd = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate stride buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate stride buffer"); } if (NULL == count) { @@ -1296,7 +1296,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sget_regular_hyperslab: count not pinned"); if (NULL == (cnt = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate count buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate count buffer"); } if (NULL == block) { @@ -1315,7 +1315,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sget_regular_hyperslab: block not pinned"); if (NULL == (blk = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate block buffer"); } if ((status = H5Sget_regular_hyperslab(space_id, (hsize_t *) strt, (hsize_t *) strd, (hsize_t *) cnt, (hsize_t *) blk)) < 0) diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 1adff3c..1cbf1a5 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -1239,7 +1239,7 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof_int: name size < 0"); if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof_int: failed to allocate name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tenum_nameof_int: failed to allocate name buffer"); PIN_INT_ARRAY(ENVONLY, value, intP, &isCopy, "H5Tenum_nameof_int: value not pinned"); @@ -1285,7 +1285,7 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: value is NULL"); if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Tenum_nameof: value not pinned"); @@ -1485,7 +1485,7 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1dims } if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tget_array_dims: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tget_array_dims: failed to allocate dimension buffer"); if ((ndims = H5Tget_array_dims2((hid_t)type_id, cdims)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1626,10 +1626,10 @@ Java_hdf_hdf5lib_H5__1H5Tarray_1create2 } if (dlen != rank) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_create: dimension array length != array rank"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dimension array length != array rank"); if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_create: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tarray_create: failed to allocate dimension buffer"); for (i = 0; i < (size_t) dlen; i++) { cdims[i] = (hsize_t)dimsP[i]; @@ -1676,7 +1676,7 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 } if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_get_dims2: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tarray_get_dims2: failed to allocate dimension buffer"); if ((ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t*)cdims)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 5c82edc..55f7571 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -515,7 +515,7 @@ h5str_convert total_elmts *= dims[i]; if (NULL == (cptr = (char *) HDcalloc((size_t)total_elmts, baseTypeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to allocate array buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to allocate array buffer"); for (i = 0; i < total_elmts; i++) { if (!(h5str_convert(ENVONLY, &this_str, container, mtid, out_buf, i * baseTypeSize))) { @@ -556,7 +556,7 @@ h5str_convert H5_LIBRARY_ERROR(ENVONLY); if (NULL == (vl_buf->p = HDmalloc(baseTypeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to allocate vlen buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to allocate vlen buffer"); vl_buf->len = 1; /* Skip whitespace and vlen indicators */ @@ -570,7 +570,7 @@ h5str_convert char *tmp_realloc; if (NULL == (tmp_realloc = (char *) HDrealloc(vl_buf->p, vl_buf->len * 2 * baseTypeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to reallocate vlen buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to reallocate vlen buffer"); vl_buf->len *= 2; vl_buf->p = tmp_realloc; } @@ -733,9 +733,9 @@ h5str_sprintf /* Build default formats for long long types */ if (!fmt_llong[0]) { if (HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure"); + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); if (HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%%su", H5_PRINTF_LL_WIDTH) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure"); + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } /* end if */ switch (tclass) { @@ -749,7 +749,7 @@ h5str_sprintf HDmemcpy(&tmp_float, cptr, sizeof(float)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%g", tmp_float) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -764,7 +764,7 @@ h5str_sprintf HDmemcpy(&tmp_double, cptr, sizeof(double)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%g", tmp_double) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -779,7 +779,7 @@ h5str_sprintf HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); if (NULL == (this_str = (char *) HDmalloc(27))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%Lf", tmp_ldouble) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -819,13 +819,13 @@ h5str_sprintf /* Check for NULL pointer for string */ if (!tmp_str) { if (NULL == (this_str = (char *) HDmalloc(5))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, "NULL", 5); } else { if (typeSize > 0) { if (NULL == (this_str = (char *) HDmalloc(typeSize + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, tmp_str, typeSize); this_str[typeSize] = '\0'; @@ -851,7 +851,7 @@ h5str_sprintf HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char)); if (NULL == (this_str = (char *) HDmalloc(7))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hhu", tmp_uchar) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -860,7 +860,7 @@ h5str_sprintf HDmemcpy(&tmp_char, cptr, sizeof(char)); if (NULL == (this_str = (char *) HDmalloc(7))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hhd", tmp_char) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -878,7 +878,7 @@ h5str_sprintf HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); if (NULL == (this_str = (char *) HDmalloc(9))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hu", tmp_ushort) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -887,7 +887,7 @@ h5str_sprintf HDmemcpy(&tmp_short, cptr, sizeof(short)); if (NULL == (this_str = (char *) HDmalloc(9))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hd", tmp_short) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -905,7 +905,7 @@ h5str_sprintf HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int)); if (NULL == (this_str = (char *) HDmalloc(14))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%u", tmp_uint) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -914,7 +914,7 @@ h5str_sprintf HDmemcpy(&tmp_int, cptr, sizeof(int)); if (NULL == (this_str = (char *) HDmalloc(14))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%d", tmp_int) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -932,7 +932,7 @@ h5str_sprintf HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); if (NULL == (this_str = (char *) HDmalloc(23))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%lu", tmp_ulong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -941,7 +941,7 @@ h5str_sprintf HDmemcpy(&tmp_long, cptr, sizeof(long)); if (NULL == (this_str = (char *) HDmalloc(23))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%ld", tmp_long) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -960,7 +960,7 @@ h5str_sprintf HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, fmt_ullong, tmp_ullong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -969,7 +969,7 @@ h5str_sprintf HDmemcpy(&tmp_llong, cptr, sizeof(long long)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, fmt_llong, tmp_llong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -1034,7 +1034,7 @@ h5str_sprintf size_t i; if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) @@ -1069,10 +1069,10 @@ h5str_sprintf case H5R_OBJECT1: { /* Object references -- show the type and OID of the referenced object. */ - H5O_info_t oi; + H5O_info2_t oi; if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - H5Oget_info2(obj, &oi, H5O_INFO_BASIC); + H5Oget_info3(obj, &oi, H5O_INFO_BASIC); if(H5Oclose(obj) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } @@ -1080,7 +1080,7 @@ h5str_sprintf CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (NULL == (this_str = (char *) HDmalloc(14))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); 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)) @@ -1114,10 +1114,19 @@ h5str_sprintf h5str_sprint_reference(ENVONLY, out_str, container, ref_vp); /* Print OID */ - if (NULL == (this_str = (char *) HDmalloc(64))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%lu:"H5_PRINTF_HADDR_FMT" ", oi.fileno, oi.addr) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + { + char *token_str; + + H5Otoken_to_str(tid, &oi.token, &token_str); + + if (NULL == (this_str = (char *) HDmalloc(64 + strlen(token_str) + 1))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (HDsprintf(this_str, "%lu:%s", oi.fileno, token_str) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + + H5free_memory(token_str); + } + } break; @@ -1273,7 +1282,7 @@ h5str_sprintf /* All other types get printed as hexadecimal */ if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) @@ -1346,7 +1355,7 @@ h5str_print_region_data_blocks /* Allocate space for the dimension array */ if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); /* Find the dimensions of each data space from the block coordinates */ for (jndx = 0, numelem = 1; jndx < (size_t) ndims; jndx++) { @@ -1362,15 +1371,15 @@ h5str_print_region_data_blocks H5_LIBRARY_ERROR(ENVONLY); if (NULL == (region_buf = HDmalloc(type_size * (size_t)numelem))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate region buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate region buffer"); /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ if (NULL == (start = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); if (NULL == (count = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); for (blkndx = 0; blkndx < (hsize_t) nblocks; blkndx++) { for (indx = 0; indx < (unsigned) ndims; indx++) { @@ -1445,7 +1454,7 @@ h5str_dump_region_blocks_data alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks_data: failed to allocate region block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_blocks_data: failed to allocate region block buffer"); if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1505,7 +1514,7 @@ h5str_dump_region_blocks int i; if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: failed to allocate region block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_blocks: failed to allocate region block buffer"); if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1590,7 +1599,7 @@ h5str_print_region_data_points /* Allocate space for the dimension array */ if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate dimension array buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate dimension array buffer"); dims1[0] = (hsize_t)npoints; @@ -1602,7 +1611,7 @@ h5str_print_region_data_points H5_LIBRARY_ERROR(ENVONLY); if (NULL == (region_buf = HDmalloc(type_size * (size_t)npoints))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate region buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate region buffer"); if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1662,7 +1671,7 @@ h5str_dump_region_points_data alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1725,7 +1734,7 @@ h5str_dump_region_points alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: failed to allocate region point buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_points: failed to allocate region point buffer"); if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -2833,7 +2842,7 @@ h5str_dump_simple_dset if (sm_nbytes > 0) { if (NULL == (sm_buf = (unsigned char *) HDmalloc((size_t)sm_nbytes))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf"); sm_nelmts = sm_nbytes / p_type_nbytes; @@ -2964,7 +2973,7 @@ h5tools_dump_simple_data h5str_new(&buffer, 32 * size); if (!buffer.s) - H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5tools_dump_simple_data: failed to allocate buffer"); if (!(bytes_in = h5str_sprintf(ENVONLY, &buffer, container, type, memref, 0, 1))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -3035,7 +3044,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex } if (NULL == (readBuf = (char *) HDmalloc((size_t)n * size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadComplex: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadComplex: failed to allocate read buffer"); if ((status = H5Aread(attr_id, mem_type_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3043,7 +3052,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex h5str_new(&h5str, 4 * size); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadComplex: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadComplex: failed to allocate string buffer"); for (i = 0; i < (size_t) n; i++) { h5str.s[0] = '\0'; @@ -3104,7 +3113,7 @@ Java_hdf_hdf5lib_H5_H5Acopy total_size = (hsize_t)npoints * (hsize_t)type_size; if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Acopy: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Acopy: failed to allocate buffer"); if ((retVal = H5Aread((hid_t)src_id, tid, buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3151,7 +3160,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy UNUSED(clss); if (!(total_allocated_size = H5Dget_storage_size((hid_t)src_id))) - return 0; // nothing to write + return 0; /* nothing to write */ if ((sid = H5Dget_space((hid_t)src_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3166,7 +3175,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy total_size = (hsize_t)npoints * (hsize_t)type_size; if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dcopy: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dcopy: failed to allocate buffer"); if ((retVal = H5Dread((hid_t)src_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3204,15 +3213,15 @@ done: */ #ifdef __cplusplus - herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); - herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); - int H5Gget_obj_info_max(hid_t, char **, int *, int *, unsigned long *, long); - int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder); + herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); + herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); + int H5Gget_obj_info_max(hid_t, char **, int *, int *, H5O_token_t *, long); + int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, H5O_token_t *obj_token, int indexType, int indexOrder); #else - static herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); - static herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); - static int H5Gget_obj_info_max(hid_t, char **, int *, int *, unsigned long *, long); - static int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder); + static herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); + static herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); + static int H5Gget_obj_info_max(hid_t, char **, int *, int *, H5O_token_t *, long); + static int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, H5O_token_t *obj_token, int indexType, int indexOrder); #endif typedef struct info_all @@ -3220,7 +3229,7 @@ typedef struct info_all char **objname; int *otype; int *ltype; - unsigned long *objno; + H5O_token_t *obj_token; unsigned long *fno; unsigned long idxnum; int count; @@ -3241,17 +3250,17 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full (JNIEnv *env, jclass clss, jlong loc_id, jstring group_name, jobjectArray objName, jintArray oType, jintArray lType, jlongArray fNo, - jlongArray oRef, jint n, jint indx_type, jint indx_order) + jobjectArray oToken, jint n, jint indx_type, jint indx_order) { - unsigned long *refs = NULL; unsigned long *fnos = NULL; + H5O_token_t *tokens = NULL; const char *gName = NULL; char **oName = NULL; jboolean isCopy; jstring str; + jobject token; jint *otarr = NULL; jint *ltarr = NULL; - jlong *refP = NULL; jlong *fnoP = NULL; hid_t gid = (hid_t)loc_id; int i; @@ -3265,24 +3274,23 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: oType is NULL"); if (NULL == lType) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: lType is NULL"); - if (NULL == oRef) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: oRef is NULL"); + if (NULL == oToken) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: oToken is NULL"); if (NULL == fNo) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: fNo is NULL"); PIN_INT_ARRAY(ENVONLY, oType, otarr, &isCopy, "H5Gget_obj_info_full: oType not pinned"); PIN_INT_ARRAY(ENVONLY, lType, ltarr, &isCopy, "H5Gget_obj_info_full: lType not pinned"); - PIN_LONG_ARRAY(ENVONLY, oRef, refP, &isCopy, "H5Gget_obj_info_full: oRef not pinned"); PIN_LONG_ARRAY(ENVONLY, fNo, fnoP, &isCopy, "H5Gget_obj_info_full: fNo not pinned"); if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object name"); - if (NULL == (refs = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for ref. info"); + if (NULL == (tokens = (H5O_token_t *) HDcalloc((size_t)n, sizeof(H5O_token_t)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object tokens"); if (NULL == (fnos = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for file number info"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for file number info"); if (group_name) { PIN_JAVA_STRING(ENVONLY, group_name, gName, &isCopy, "H5Gget_obj_info_full: group_name not pinned"); @@ -3291,11 +3299,10 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full H5_LIBRARY_ERROR(ENVONLY); } - if ((ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, refs, indexType, indexOrder)) < 0) + if ((ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, tokens, indexType, indexOrder)) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: retrieval of object info failed"); for (i = 0; i < n; i++) { - refP[i] = (jlong)refs[i]; fnoP[i] = (jlong)fnos[i]; if (oName[i]) { @@ -3307,6 +3314,15 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full ENVPTR->DeleteLocalRef(ENVONLY, str); } /* end if */ + + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(ENVONLY, &tokens[i], TRUE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, oToken, i, token); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, token); } done: @@ -3316,14 +3332,12 @@ done: } if (fnos) HDfree(fnos); - if (refs) - HDfree(refs); + if (tokens) + HDfree(tokens); if (oName) h5str_array_free(oName, (size_t)n); if (fnoP) UNPIN_LONG_ARRAY(ENVONLY, fNo, fnoP, (ret_val < 0) ? JNI_ABORT : 0); - if (refP) - UNPIN_LONG_ARRAY(ENVONLY, oRef, refP, (ret_val < 0) ? JNI_ABORT : 0); if (ltarr) UNPIN_INT_ARRAY(ENVONLY, lType, ltarr, (ret_val < 0) ? JNI_ABORT : 0); if (otarr) @@ -3345,17 +3359,17 @@ done: JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max (JNIEnv *env, jclass clss, jlong loc_id, jobjectArray objName, - jintArray oType, jintArray lType, jlongArray oRef, jlong maxnum, jint n) + jintArray oType, jintArray lType, jobjectArray oToken, jlong maxnum, jint n) { - unsigned long *refs = NULL; - jboolean isCopy; - jstring str; - jlong *refP = NULL; - char **oName = NULL; - jint *otarr = NULL; - jint *ltarr = NULL; - int i; - herr_t ret_val = FAIL; + H5O_token_t *tokens = NULL; + jboolean isCopy; + jstring str; + jobject token; + char **oName = NULL; + jint *otarr = NULL; + jint *ltarr = NULL; + int i; + herr_t ret_val = FAIL; UNUSED(clss); @@ -3363,25 +3377,22 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: oType is NULL"); if (NULL == lType) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: lType is NULL"); - if (NULL == oRef) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: oRef is NULL"); + if (NULL == oToken) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: oToken is NULL"); PIN_INT_ARRAY(ENVONLY, oType, otarr, &isCopy, "H5Gget_obj_info_max: oType not pinned"); PIN_INT_ARRAY(ENVONLY, lType, ltarr, &isCopy, "H5Gget_obj_info_max: lType not pinned"); - PIN_LONG_ARRAY(ENVONLY, oRef, refP, &isCopy, "H5Gget_obj_info_max: oRef not pinned"); if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object name"); - if (NULL == (refs = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for ref. info"); + if (NULL == (tokens = (H5O_token_t *) HDcalloc((size_t)n, sizeof(H5O_token_t)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object tokens"); - if ((ret_val = H5Gget_obj_info_max((hid_t)loc_id, oName, (int *)otarr, (int *)ltarr, refs, maxnum)) < 0) + if ((ret_val = H5Gget_obj_info_max((hid_t)loc_id, oName, (int *)otarr, (int *)ltarr, tokens, maxnum)) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: retrieval of object info failed"); for (i = 0; i < n; i++) { - refP[i] = (jlong) refs[i]; - if (oName[i]) { if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, oName[i]))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -3391,15 +3402,22 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max ENVPTR->DeleteLocalRef(ENVONLY, str); } + + /* Create an H5O_token_t object */ + if (NULL == (token = create_H5O_token_t(ENVONLY, &tokens[i], TRUE))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, oToken, i, token); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, token); } /* end for */ done: - if (refs) - HDfree(refs); + if (tokens) + HDfree(tokens); if (oName) h5str_array_free(oName, (size_t)n); - if (refP) - UNPIN_LONG_ARRAY(ENVONLY, oRef, refP, (ret_val < 0) ? JNI_ABORT : 0); if (ltarr) UNPIN_INT_ARRAY(ENVONLY, lType, ltarr, (ret_val < 0) ? JNI_ABORT : 0); if (otarr) @@ -3410,7 +3428,7 @@ done: int H5Gget_obj_info_full - (hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder) + (hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, H5O_token_t *obj_token, int indexType, int indexOrder) { info_all_t info; @@ -3419,10 +3437,10 @@ H5Gget_obj_info_full info.ltype = ltype; info.idxnum = 0; info.fno = fno; - info.objno = objno; + info.obj_token = obj_token; info.count = 0; - if (H5Literate(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, (void *)&info) < 0) { + if (H5Literate2(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, (void *)&info) < 0) { /* * Reset info stats; most importantly, reset the count. */ @@ -3431,11 +3449,11 @@ H5Gget_obj_info_full info.ltype = ltype; info.idxnum = 0; info.fno = fno; - info.objno = objno; + info.obj_token = obj_token; info.count = 0; /* Iteration failed, try normal alphabetical order */ - if (H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, obj_info_all, (void *)&info) < 0) + if (H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, obj_info_all, (void *)&info) < 0) return -1; } @@ -3444,7 +3462,7 @@ H5Gget_obj_info_full int H5Gget_obj_info_max - (hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *objno, long maxnum) + (hid_t loc_id, char **objname, int *otype, int *ltype, H5O_token_t *obj_token, long maxnum) { info_all_t info; @@ -3452,10 +3470,10 @@ H5Gget_obj_info_max info.otype = otype; info.ltype = ltype; info.idxnum = (unsigned long)maxnum; - info.objno = objno; + info.obj_token = obj_token; info.count = 0; - if (H5Lvisit(loc_id, H5_INDEX_NAME, H5_ITER_NATIVE, obj_info_max, (void *)&info) < 0) + if (H5Lvisit2(loc_id, H5_INDEX_NAME, H5_ITER_NATIVE, obj_info_max, (void *)&info) < 0) return -1; return info.count; @@ -3463,16 +3481,16 @@ H5Gget_obj_info_max herr_t obj_info_all - (hid_t loc_id, const char *name, const H5L_info_t *info, void *op_data) + (hid_t loc_id, const char *name, const H5L_info2_t *info, void *op_data) { - info_all_t *datainfo = (info_all_t *)op_data; - H5O_info_t object_info; - htri_t object_exists; - size_t str_len; + info_all_t *datainfo = (info_all_t *)op_data; + H5O_info2_t object_info; + htri_t object_exists; + size_t str_len; datainfo->otype[datainfo->count] = -1; datainfo->ltype[datainfo->count] = -1; - datainfo->objno[datainfo->count] = (unsigned long)-1; + datainfo->obj_token[datainfo->count] = H5O_TOKEN_UNDEF; str_len = HDstrlen(name); if (NULL == (datainfo->objname[datainfo->count] = (char *) HDmalloc(str_len + 1))) @@ -3485,21 +3503,15 @@ obj_info_all goto done; if (object_exists) { - if (H5Oget_info_by_name2(loc_id, name, &object_info, H5O_INFO_ALL, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(loc_id, name, &object_info, H5O_INFO_ALL, H5P_DEFAULT) < 0) goto done; datainfo->otype[datainfo->count] = object_info.type; datainfo->ltype[datainfo->count] = info->type; datainfo->fno[datainfo->count] = object_info.fileno; - datainfo->objno[datainfo->count] = (unsigned long)object_info.addr; - } - /* - if (info->type == H5L_TYPE_HARD) - datainfo->objno[datainfo->count] = (unsigned long)info->u.address; - else - datainfo->objno[datainfo->count] = info->u.val_size; - */ + HDmemcpy(&datainfo->obj_token[datainfo->count], &object_info.token, sizeof(object_info.token)); + } done: datainfo->count++; @@ -3509,16 +3521,16 @@ done: herr_t obj_info_max - (hid_t loc_id, const char *name, const H5L_info_t *info, void *op_data) + (hid_t loc_id, const char *name, const H5L_info2_t *info, void *op_data) { - info_all_t *datainfo = (info_all_t *)op_data; - H5O_info_t object_info; - size_t str_len; + info_all_t *datainfo = (info_all_t *)op_data; + H5O_info2_t object_info; + size_t str_len; datainfo->otype[datainfo->count] = -1; datainfo->ltype[datainfo->count] = -1; datainfo->objname[datainfo->count] = NULL; - datainfo->objno[datainfo->count] = (unsigned long)-1; + datainfo->obj_token[datainfo->count] = H5O_TOKEN_UNDEF; /* This will be freed by h5str_array_free(oName, n) */ str_len = HDstrlen(name); @@ -3528,16 +3540,13 @@ obj_info_max HDstrncpy(datainfo->objname[datainfo->count], name, str_len); (datainfo->objname[datainfo->count])[str_len] = '\0'; - if (H5Oget_info2(loc_id, &object_info, H5O_INFO_ALL) < 0) + if (H5Oget_info3(loc_id, &object_info, H5O_INFO_ALL) < 0) goto done; datainfo->otype[datainfo->count] = object_info.type; datainfo->ltype[datainfo->count] = info->type; - if (info->type == H5L_TYPE_HARD) - datainfo->objno[datainfo->count] = (unsigned long)info->u.address; - else - datainfo->objno[datainfo->count] = info->u.val_size; + HDmemcpy(&datainfo->obj_token[datainfo->count], &object_info.token, sizeof(object_info.token)); done: datainfo->count++; diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index c26cd5d..51b6594 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -96,7 +96,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full - (JNIEnv*, jclass, jlong, jstring, jobjectArray, jintArray, jintArray, jlongArray, jlongArray, jint, jint, jint); + (JNIEnv*, jclass, jlong, jstring, jobjectArray, jintArray, jintArray, jlongArray, jobjectArray, jint, jint, jint); /* * Class: hdf_hdf5lib_H5 diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c index 92e456e..0fee343 100644 --- a/java/src/jni/h5vlImp.c +++ b/java/src/jni/h5vlImp.c @@ -110,10 +110,30 @@ done: /* * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_id - * Signature: (Ljava/lang/String;)J + * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1id + (JNIEnv *env, jclass clss, jlong obj_id) +{ + hid_t status = H5I_INVALID_HID; + + UNUSED(clss); + + if ((status = H5VLget_connector_id((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id_by_name + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name (JNIEnv *env, jclass clss, jobject connector_name) { const char *volName = NULL; @@ -122,11 +142,11 @@ Java_hdf_hdf5lib_H5_H5VLget_1connector_1id UNUSED(clss); if (NULL == connector_name) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id: VOL connector name is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id_by_name: VOL connector name is NULL"); - PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id: VOL connector name not pinned"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id_by_name: VOL connector name not pinned"); - if ((status = H5VLget_connector_id(volName)) < 0) + if ((status = H5VLget_connector_id_by_name(volName)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -134,7 +154,7 @@ done: UNPIN_JAVA_STRING(ENVONLY, connector_name, volName); return (jlong)status; -} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */ +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name */ /* * Class: hdf_hdf5lib_H5 @@ -158,7 +178,7 @@ Java_hdf_hdf5lib_H5_H5VLget_1connector_1name if (buf_size > 0) { if (NULL == (volName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5VLget_connector_name: failed to allocated VOL connector name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5VLget_connector_name: failed to allocated VOL connector name buffer"); if ((status = H5VLget_connector_name((hid_t)object_id, volName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h index 207efa5..6dd7529 100644 --- a/java/src/jni/h5vlImp.h +++ b/java/src/jni/h5vlImp.h @@ -50,10 +50,19 @@ Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered /* * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_id - * Signature: (Ljava/lang/String;)J + * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1id + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id_by_name + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name (JNIEnv *, jclass, jobject); /* diff --git a/java/src/jni/nativeData.c b/java/src/jni/nativeData.c index ad01b01..3c3d3d5 100644 --- a/java/src/jni/nativeData.c +++ b/java/src/jni/nativeData.c @@ -327,7 +327,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jint))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToInt: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -379,7 +379,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jshort))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToShort: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -431,7 +431,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jfloat))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToFloat: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -483,7 +483,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jlong))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToLong: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -535,7 +535,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jdouble))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToDouble: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -593,7 +593,7 @@ Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "intToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "intToByte: start < 0 or len exceeded buffer length"); ip = iarr + start; @@ -655,7 +655,7 @@ Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "shortToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "shortToByte: start < 0 or len exceeded buffer length"); ip = sarr + start; @@ -717,7 +717,7 @@ Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "floatToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "floatToByte: start < 0 or len exceeded buffer length"); ip = farr + start; @@ -779,7 +779,7 @@ Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "doubleToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "doubleToByte: start < 0 or len exceeded buffer length"); ip = darr + start; @@ -841,7 +841,7 @@ Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "longToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "longToByte: start < 0 or len exceeded buffer length"); ip = larr + start; |