1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14 /*
15 * For details of the HDF libraries, see the HDF Documentation at:
16 * http://hdfgroup.org/HDF5/doc/
17 *
18 */
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23
24 /*
25 * This code is the C-interface called by Java programs to access the
26 * general library functions of the HDF5 library.
27 *
28 * Each routine wraps a single HDF entry point, generally with the
29 * analogous arguments and return codes.
30 *
31 * For details of the HDF libraries, see the HDF Documentation at:
32 * http://www.hdfgroup.org/HDF5/doc/
33 *
34 */
35
36 #include <jni.h>
37 #include <stdlib.h>
38 #include "hdf5.h"
39 #include "h5jni.h"
40 #include "h5eImp.h"
41
42 /*
43 * Pointer to the JNI's Virtual Machine; used for callback functions.
44 */
45 extern JavaVM *jvm;
46
47 typedef struct _cb_wrapper {
48 jobject visit_callback;
49 jobject op_data;
50 } cb_wrapper;
51
52 /********************/
53 /* Local Prototypes */
54 /********************/
55
56 static herr_t H5E_walk_cb(int nindx, const H5E_error2_t *info, void *cb_data);
57
58 /*
59 * Class: hdf_hdf5lib_H5
60 * Method: H5Eauto_is_v2
61 * Signature: (J)Z
62 */
63 JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2(JNIEnv * env,jclass clss,jlong stk_id)64 Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2
65 (JNIEnv *env, jclass clss, jlong stk_id)
66 {
67 unsigned int is_stack = 0;
68
69 UNUSED(clss);
70
71 if (stk_id < 0)
72 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eauto_is_v2: invalid stack ID");
73
74 if (H5Eauto_is_v2((hid_t)stk_id, &is_stack) < 0)
75 H5_LIBRARY_ERROR(ENVONLY);
76
77 done:
78 return (jboolean)is_stack;
79 } /* end Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 */
80
81 /*
82 * Class: hdf_hdf5lib_H5
83 * Method: H5Eregister_class
84 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
85 */
86 JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Eregister_1class(JNIEnv * env,jclass clss,jstring cls_name,jstring lib_name,jstring version)87 Java_hdf_hdf5lib_H5_H5Eregister_1class
88 (JNIEnv *env, jclass clss, jstring cls_name, jstring lib_name, jstring version)
89 {
90 const char* the_cls_name = NULL;
91 const char* the_lib_name = NULL;
92 const char* the_version = NULL;
93 hid_t ret_val = H5I_INVALID_HID;
94
95 UNUSED(clss);
96
97 if (NULL == cls_name)
98 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eregister_class: class name is NULL");
99 if (NULL == lib_name)
100 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eregister_class: lib name is NULL");
101 if (NULL == version)
102 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eregister_class: version string is NULL");
103
104 PIN_JAVA_STRING(ENVONLY, cls_name, the_cls_name, NULL, "H5Eregister_class: class name not pinned");
105 PIN_JAVA_STRING(ENVONLY, lib_name, the_lib_name, NULL, "H5Eregister_class: lib name not pinned");
106 PIN_JAVA_STRING(ENVONLY, version, the_version, NULL, "H5Eregister_class: version string not pinned");
107
108 if ((ret_val = H5Eregister_class(the_cls_name, the_lib_name, the_version)) < 0)
109 H5_LIBRARY_ERROR(ENVONLY);
110
111 done:
112 if (the_version)
113 UNPIN_JAVA_STRING(ENVONLY, version, the_version);
114 if (the_lib_name)
115 UNPIN_JAVA_STRING(ENVONLY, lib_name, the_lib_name);
116 if (the_cls_name)
117 UNPIN_JAVA_STRING(ENVONLY, cls_name, the_cls_name);
118
119 return (jlong)ret_val;
120 } /* end Java_hdf_hdf5lib_H5_H5Eregister_1class */
121
122 /*
123 * Class: hdf_hdf5lib_H5
124 * Method: H5Eunregister_class
125 * Signature: (J)V
126 */
127 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Eunregister_1class(JNIEnv * env,jclass clss,jlong cls_id)128 Java_hdf_hdf5lib_H5_H5Eunregister_1class
129 (JNIEnv *env, jclass clss, jlong cls_id)
130 {
131 UNUSED(clss);
132
133 if (cls_id < 0)
134 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eunregister_class: invalid error class ID");
135
136 if (H5Eunregister_class((hid_t)cls_id) < 0)
137 H5_LIBRARY_ERROR(ENVONLY);
138
139 done:
140 return;
141 } /* end Java_hdf_hdf5lib_H5_H5Eunregister_1class */
142
143 /*
144 * Class: hdf_hdf5lib_H5
145 * Method: H5Eclose_msg
146 * Signature: (J)V
147 */
148 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Eclose_1msg(JNIEnv * env,jclass clss,jlong err_id)149 Java_hdf_hdf5lib_H5_H5Eclose_1msg
150 (JNIEnv *env, jclass clss, jlong err_id)
151 {
152 UNUSED(clss);
153
154 if (err_id < 0)
155 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eclose_msg: invalid error message ID");
156
157 if (H5Eclose_msg((hid_t)err_id) < 0)
158 H5_LIBRARY_ERROR(ENVONLY);
159
160 done:
161 return;
162 } /* end Java_hdf_hdf5lib_H5_H5Eclose_1msg */
163
164 /*
165 * Class: hdf_hdf5lib_H5
166 * Method: H5Ecreate_msg
167 * Signature: (JILjava/lang/String;)J
168 */
169 JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ecreate_1msg(JNIEnv * env,jclass clss,jlong err_id,jint msg_type,jstring err_msg)170 Java_hdf_hdf5lib_H5_H5Ecreate_1msg
171 (JNIEnv *env, jclass clss, jlong err_id, jint msg_type, jstring err_msg)
172 {
173 H5E_type_t error_msg_type = (H5E_type_t)msg_type;
174 const char *the_err_msg = NULL;
175 hid_t ret_val = H5I_INVALID_HID;
176
177 UNUSED(clss);
178
179 if (err_id < 0)
180 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Ecreate_msg: invalid error class ID");
181 if (NULL == err_msg)
182 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ecreate_msg: error message string is NULL");
183
184 PIN_JAVA_STRING(ENVONLY, err_msg, the_err_msg, NULL, "H5Ecreate_msg: error message string not pinned");
185
186 if ((ret_val = H5Ecreate_msg((hid_t)err_id, error_msg_type, the_err_msg)) < 0)
187 H5_LIBRARY_ERROR(ENVONLY);
188
189 done:
190 if (the_err_msg)
191 UNPIN_JAVA_STRING(ENVONLY, err_msg, the_err_msg);
192
193 return (jlong)ret_val;
194 } /* end Java_hdf_hdf5lib_H5_H5Ecreate_1msg */
195
196 /*
197 * Class: hdf_hdf5lib_H5
198 * Method: H5Ecreate_stack
199 * Signature: ()J
200 */
201 JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ecreate_1stack(JNIEnv * env,jclass clss)202 Java_hdf_hdf5lib_H5_H5Ecreate_1stack
203 (JNIEnv *env, jclass clss)
204 {
205 hid_t ret_val = H5I_INVALID_HID;
206
207 UNUSED(clss);
208
209 if ((ret_val = H5Ecreate_stack()) < 0)
210 H5_LIBRARY_ERROR(ENVONLY);
211
212 done:
213 return (jlong)ret_val;
214 } /* end Java_hdf_hdf5lib_H5_H5Ecreate_1stack */
215
216 /*
217 * Class: hdf_hdf5lib_H5
218 * Method: H5Eget_current_stack
219 * Signature: ()J
220 */
221 JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Eget_1current_1stack(JNIEnv * env,jclass clss)222 Java_hdf_hdf5lib_H5_H5Eget_1current_1stack
223 (JNIEnv *env, jclass clss)
224 {
225 hid_t ret_val = H5I_INVALID_HID;
226
227 UNUSED(clss);
228
229 if ((ret_val = H5Eget_current_stack()) < 0)
230 H5_LIBRARY_ERROR(ENVONLY);
231
232 done:
233 return (jlong)ret_val;
234 } /* end Java_hdf_hdf5lib_H5_H5Eget_1current_1stack */
235
236 /*
237 * Class: hdf_hdf5lib_H5
238 * Method: H5Eclose_stack
239 * Signature: (J)V
240 */
241 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Eclose_1stack(JNIEnv * env,jclass clss,jlong stk_id)242 Java_hdf_hdf5lib_H5_H5Eclose_1stack
243 (JNIEnv *env, jclass clss, jlong stk_id)
244 {
245 UNUSED(clss);
246
247 if (stk_id < 0)
248 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eclose_stack: invalid error stack ID");
249
250 if (H5Eclose_stack((hid_t)stk_id) < 0)
251 H5_LIBRARY_ERROR(ENVONLY);
252
253 done:
254 return;
255 } /* end Java_hdf_hdf5lib_H5_H5Eclose_1stack */
256
257 /*
258 * Class: hdf_hdf5lib_H5
259 * Method: H5Eprint2
260 * Signature: (JLjava/lang/Object;)V
261 */
262 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Eprint2(JNIEnv * env,jclass clss,jlong stk_id,jobject stream_obj)263 Java_hdf_hdf5lib_H5_H5Eprint2
264 (JNIEnv *env, jclass clss, jlong stk_id, jobject stream_obj)
265 {
266 herr_t ret_val = FAIL;
267
268 UNUSED(clss);
269
270 if (stk_id < 0)
271 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eprint2: invalid error stack ID");
272
273 if (!stream_obj) {
274 if ((ret_val = H5Eprint2((hid_t)stk_id, stdout)) < 0)
275 H5_LIBRARY_ERROR(ENVONLY);
276 }
277 else {
278 if ((ret_val = H5Eprint2((hid_t)stk_id, (FILE *)stream_obj)) < 0)
279 H5_LIBRARY_ERROR(ENVONLY);
280 }
281
282 done:
283 return;
284 } /* end Java_hdf_hdf5lib_H5_H5Eprint2 */
285
286 /*
287 * Class: hdf_hdf5lib_H5
288 * Method: H5Eget_class_name
289 * Signature: (J)Ljava/lang/String;
290 */
291 JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Eget_1class_1name(JNIEnv * env,jclass clss,jlong cls_id)292 Java_hdf_hdf5lib_H5_H5Eget_1class_1name
293 (JNIEnv *env, jclass clss, jlong cls_id)
294 {
295 jstring str = NULL;
296 ssize_t buf_size;
297 char *namePtr = NULL;
298
299 UNUSED(clss);
300
301 if (cls_id < 0)
302 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: invalid error class ID");
303
304 /* Get the length of the name */
305 if ((buf_size = H5Eget_class_name((hid_t)cls_id, NULL, 0)) < 0)
306 H5_LIBRARY_ERROR(ENVONLY);
307
308 if (!buf_size)
309 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: no class name");
310
311 if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
312 H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_class_name: malloc failed");
313
314 if ((H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size + 1)) < 0)
315 H5_LIBRARY_ERROR(ENVONLY);
316 namePtr[buf_size] = '\0';
317
318 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr)))
319 CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
320
321 done:
322 if (namePtr)
323 HDfree(namePtr);
324
325 return str;
326 } /* end Java_hdf_hdf5lib_H5_H5Eget_1class_1name */
327
328 /*
329 * Class: hdf_hdf5lib_H5
330 * Method: H5Eset_current_stack
331 * Signature: (J)V
332 */
333 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Eset_1current_1stack(JNIEnv * env,jclass clss,jlong stk_id)334 Java_hdf_hdf5lib_H5_H5Eset_1current_1stack
335 (JNIEnv *env, jclass clss, jlong stk_id)
336 {
337 UNUSED(clss);
338
339 if (stk_id < 0)
340 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eset_current_stack: invalid error stack ID");
341
342 if (H5Eset_current_stack((hid_t)stk_id) < 0)
343 H5_LIBRARY_ERROR(ENVONLY);
344
345 done:
346 return;
347 } /* end Java_hdf_hdf5lib_H5_H5Eset_1current_1stack */
348
349 /*
350 * Class: hdf_hdf5lib_H5
351 * Method: H5Epop
352 * Signature: (JJ)V
353 */
354 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Epop(JNIEnv * env,jclass clss,jlong stk_id,jlong count)355 Java_hdf_hdf5lib_H5_H5Epop
356 (JNIEnv *env, jclass clss, jlong stk_id, jlong count)
357 {
358 UNUSED(clss);
359
360 if (stk_id < 0)
361 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epop: invalid error stack ID");
362
363 if (H5Epop((hid_t)stk_id, (size_t)count) < 0)
364 H5_LIBRARY_ERROR(ENVONLY);
365
366 done:
367 return;
368 } /* end Java_hdf_hdf5lib_H5_H5Epop */
369
370 /*
371 * Class: hdf_hdf5lib_H5
372 * Method: H5Epush2
373 * Signature: (JLjava/lang/String;Ljava/lang/String;IJJJLjava/lang/String;)V
374 */
375 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Epush2(JNIEnv * env,jclass clss,jlong stk_id,jstring filename,jstring funcname,jint linenumber,jlong class_id,jlong major_id,jlong minor_id,jstring err_desc)376 Java_hdf_hdf5lib_H5_H5Epush2
377 (JNIEnv *env, jclass clss, jlong stk_id, jstring filename, jstring funcname,
378 jint linenumber, jlong class_id, jlong major_id, jlong minor_id, jstring err_desc)
379 {
380 const char *fName = NULL;
381 const char *fncName = NULL;
382 const char *errMsg = NULL;
383 herr_t ret_val = FAIL;
384
385 UNUSED(clss);
386
387 if (stk_id < 0)
388 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid error stack ID");
389 if (class_id < 0)
390 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid error class ID");
391 if (major_id < 0)
392 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid major error class ID");
393 if (minor_id < 0)
394 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid minor error class ID");
395 if (NULL == filename)
396 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Epush2: filename is NULL");
397 if (NULL == funcname)
398 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Epush2: function name is NULL");
399 if (NULL == err_desc)
400 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Epush2: error message is NULL");
401
402 PIN_JAVA_STRING(ENVONLY, filename, fName, NULL, "H5Epush2: filename not pinned");
403 PIN_JAVA_STRING(ENVONLY, funcname, fncName, NULL, "H5Epush2: function name not pinned");
404 PIN_JAVA_STRING(ENVONLY, err_desc, errMsg, NULL, "H5Epush2: error message not pinned");
405
406 if ((ret_val = H5Epush2((hid_t)stk_id, fName, fncName, (unsigned)linenumber, (hid_t)class_id,
407 (hid_t)major_id, (hid_t)minor_id, errMsg)) < 0)
408 H5_LIBRARY_ERROR(ENVONLY);
409
410 done:
411 if (errMsg)
412 UNPIN_JAVA_STRING(ENVONLY, err_desc, errMsg);
413 if (fncName)
414 UNPIN_JAVA_STRING(ENVONLY, funcname, fncName);
415 if (fName)
416 UNPIN_JAVA_STRING(ENVONLY, filename, fName);
417 } /* end Java_hdf_hdf5lib_H5_H5Epush2 */
418
419 /*
420 * Class: hdf_hdf5lib_H5
421 * Method: H5Eclear2
422 * Signature: (J)V
423 */
424 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Eclear2(JNIEnv * env,jclass clss,jlong stk_id)425 Java_hdf_hdf5lib_H5_H5Eclear2
426 (JNIEnv *env, jclass clss, jlong stk_id)
427 {
428 UNUSED(clss);
429
430 if (stk_id < 0)
431 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eclear2: invalid error stack ID");
432
433 if (H5Eclear2((hid_t)stk_id) < 0)
434 H5_LIBRARY_ERROR(ENVONLY);
435
436 done:
437 return;
438 } /* end Java_hdf_hdf5lib_H5_H5Eclear2 */
439
440 /*
441 * Class: hdf_hdf5lib_H5
442 * Method: H5Eget_msg
443 * Signature: (J[I)Ljava/lang/String;
444 */
445 JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Eget_1msg(JNIEnv * env,jclass clss,jlong msg_id,jintArray error_msg_type_list)446 Java_hdf_hdf5lib_H5_H5Eget_1msg
447 (JNIEnv *env, jclass clss, jlong msg_id, jintArray error_msg_type_list)
448 {
449 H5E_type_t error_msg_type;
450 jstring str = NULL;
451 ssize_t buf_size;
452 jint *theArray = NULL;
453 char *namePtr = NULL;
454
455 UNUSED(clss);
456
457 if (msg_id < 0)
458 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: invalid error message ID");
459 if (NULL == error_msg_type_list)
460 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: error_msg_type_list is NULL");
461
462 /* Get the length of the name */
463 if ((buf_size = H5Eget_msg((hid_t)msg_id, NULL, NULL, 0)) < 0)
464 H5_LIBRARY_ERROR(ENVONLY);
465
466 if (!buf_size)
467 H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: invalid message");
468
469 if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
470 H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: malloc failed");
471
472 PIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, NULL, "H5Eget_msg: error_msg_type_list not pinned");
473
474 if ((H5Eget_msg((hid_t)msg_id, &error_msg_type, (char *)namePtr, (size_t)buf_size + 1)) < 0)
475 H5_LIBRARY_ERROR(ENVONLY);
476 namePtr[buf_size] = '\0';
477
478 theArray[0] = error_msg_type;
479
480 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr)))
481 CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
482
483 done:
484 if (theArray)
485 UNPIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, 0);
486 if (namePtr)
487 HDfree(namePtr);
488
489 return str;
490 } /* end Java_hdf_hdf5lib_H5_H5Eget_1msg */
491
492 /*
493 * Class: hdf_hdf5lib_H5
494 * Method: H5Eget_num
495 * Signature: (J)J
496 */
497 JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Eget_1num(JNIEnv * env,jclass clss,jlong stk_id)498 Java_hdf_hdf5lib_H5_H5Eget_1num
499 (JNIEnv *env, jclass clss, jlong stk_id)
500 {
501 ssize_t ret_val = -1;
502
503 UNUSED(clss);
504
505 if (stk_id < 0)
506 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_num: invalid error stack ID");
507
508 if ((ret_val = H5Eget_num((hid_t)stk_id)) < 0)
509 H5_LIBRARY_ERROR(ENVONLY);
510
511 done:
512 return (jlong)ret_val;
513 } /* end Java_hdf_hdf5lib_H5_H5Eget_1num */
514
515 static herr_t
H5E_walk_cb(int nindx,const H5E_error2_t * info,void * cb_data)516 H5E_walk_cb
517 (int nindx, const H5E_error2_t *info, void *cb_data)
518 {
519 cb_wrapper *wrapper = (cb_wrapper *)cb_data;
520 jmethodID constructor;
521 jmethodID mid;
522 jobject visit_callback = wrapper->visit_callback;
523 jstring str1, str2, str3;
524 jobject cb_info_t = NULL;
525 jvalue args[7];
526 JNIEnv *cbenv = NULL;
527 jclass cls;
528 void *op_data = (void *)wrapper->op_data;
529 jint status = FAIL;
530
531 if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) {
532 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE);
533 H5_JNI_FATAL_ERROR(CBENVONLY, "H5E_walk_cb: failed to attach current thread to JVM");
534 }
535
536 if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
537 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
538
539 if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I")))
540 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
541
542 args[0].j = info->cls_id;
543 args[1].j = info->maj_num;
544 args[2].j = info->min_num;
545 args[3].i = (jint)info->line;
546
547 if (NULL == (str1 = CBENVPTR->NewStringUTF(CBENVONLY, info->func_name)))
548 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
549
550 args[4].l = str1;
551
552 if (NULL == (str2 = CBENVPTR->NewStringUTF(CBENVONLY, info->file_name)))
553 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
554
555 args[5].l = str2;
556
557 if (NULL == (str3 = CBENVPTR->NewStringUTF(CBENVONLY, info->desc)))
558 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
559
560 args[6].l = str3;
561
562 /* Get a reference to your class if you don't have it already */
563 if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t")))
564 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
565
566 /* get a reference to the constructor; the name is <init> */
567 if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V")))
568 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
569
570 if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args)))
571 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
572
573 status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, nindx, cb_info_t, op_data);
574 CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
575
576 done:
577 if (CBENVONLY)
578 JVMPTR->DetachCurrentThread(JVMPAR);
579
580 return (herr_t)status;
581 } /* end H5E_walk_cb */
582
583 /*
584 * Class: hdf_hdf5lib_H5
585 * Method: H5Ewalk2
586 * Signature: (JJLjava/lang/Object;Ljava/lang/Object;)V
587 */
588 JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Ewalk2(JNIEnv * env,jclass clss,jlong stk_id,jlong direction,jobject callback_op,jobject op_data)589 Java_hdf_hdf5lib_H5_H5Ewalk2
590 (JNIEnv *env, jclass clss, jlong stk_id, jlong direction, jobject callback_op, jobject op_data)
591 {
592 cb_wrapper wrapper = { callback_op, op_data };
593
594 UNUSED(clss);
595
596 ENVPTR->GetJavaVM(ENVONLY, &jvm);
597 CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
598
599 if (NULL == op_data)
600 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ewalk2: op_data is NULL");
601 if (NULL == callback_op)
602 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ewalk2: callback_op is NULL");
603
604 if (H5Ewalk2(stk_id, (H5E_direction_t)direction, (H5E_walk2_t)H5E_walk_cb, (void *)&wrapper) < 0)
605 H5_LIBRARY_ERROR(ENVONLY);
606
607 done:
608 return;
609 } /* end iJava_hdf_hdf5lib_H5_H5Ewalk2f */
610
611 #ifdef __cplusplus
612 } /* end extern "C" */
613 #endif /* __cplusplus */
614