-
Notifications
You must be signed in to change notification settings - Fork 0
/
jni_util.h
46 lines (38 loc) · 1.13 KB
/
jni_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Java utilities for JNI and JVMTI APIs.
*/
#ifndef JNI_UTIL_H_
#define JNI_UTIL_H_
#include <jni.h>
#include <jvmti.h>
#include "myjni.h"
typedef struct {
char *cls;
char *func;
char *sig;
jclass jcls;
jmethodID mid;
} method_decl;
jvmtiError free_jvmti_refs(jvmtiEnv *jvmti, ...);
jvmtiEventCallbacks *get_jvmti_callbacks();
jvmtiError event_change(jvmtiEnv *jvmti, jvmtiEventMode mode,
jvmtiEvent type, jthread thread);
/* utility macros to check and clear exceptions on JNI env */
#define EXCEPTION_CLEAR(JNI) \
do { \
if((*(JNI))->ExceptionCheck(JNI)) { \
(*(JNI))->ExceptionClear(JNI); \
} \
} while(0)
#include "lua_java.h" /* co-dependency for lj_print_message... */
#define EXCEPTION_CHECK(JNI) \
do { \
if ((*(JNI))->ExceptionCheck(JNI)) { \
if(IsDebuggerPresent()) \
DebugBreak(); \
lj_print_message("EXCEPTION EXISTS at %s:%d\n", __FILE__, __LINE__); \
(*(JNI))->ExceptionDescribe(JNI); \
(*(JNI))->ExceptionClear(JNI); \
} \
} while(0)
#endif /* JNI_UTIL_H_ */