Lines Matching refs:env
55 JNIEnv *env = NULL;
69 if ((env = pthread_getspecific(current_env)) != NULL) {
73 ret = (*java_vm)->GetEnv(java_vm, (void **)&env, JNI_VERSION_1_6);
76 if ((*java_vm)->AttachCurrentThread(java_vm, &env, NULL) != 0) {
78 env = NULL;
80 pthread_setspecific(current_env, env);
95 return env;
98 char *ff_jni_jstring_to_utf_chars(JNIEnv *env, jstring string, void *log_ctx)
109 utf_chars = (*env)->GetStringUTFChars(env, string, ©);
110 if ((*env)->ExceptionCheck(env)) {
111 (*env)->ExceptionClear(env);
118 (*env)->ReleaseStringUTFChars(env, string, utf_chars);
119 if ((*env)->ExceptionCheck(env)) {
120 (*env)->ExceptionClear(env);
128 jstring ff_jni_utf_chars_to_jstring(JNIEnv *env, const char *utf_chars, void *log_ctx)
132 ret = (*env)->NewStringUTF(env, utf_chars);
133 if ((*env)->ExceptionCheck(env)) {
134 (*env)->ExceptionClear(env);
142 int ff_jni_exception_get_summary(JNIEnv *env, jthrowable exception, char **error, void *log_ctx)
161 exception_class = (*env)->GetObjectClass(env, exception);
162 if ((*env)->ExceptionCheck(env)) {
163 (*env)->ExceptionClear(env);
169 class_class = (*env)->GetObjectClass(env, exception_class);
170 if ((*env)->ExceptionCheck(env)) {
171 (*env)->ExceptionClear(env);
177 get_name_id = (*env)->GetMethodID(env, class_class, "getName", "()Ljava/lang/String;");
178 if ((*env)->ExceptionCheck(env)) {
179 (*env)->ExceptionClear(env);
185 string = (*env)->CallObjectMethod(env, exception_class, get_name_id);
186 if ((*env)->ExceptionCheck(env)) {
187 (*env)->ExceptionClear(env);
194 name = ff_jni_jstring_to_utf_chars(env, string, log_ctx);
195 (*env)->DeleteLocalRef(env, string);
199 get_message_id = (*env)->GetMethodID(env, exception_class, "getMessage", "()Ljava/lang/String;");
200 if ((*env)->ExceptionCheck(env)) {
201 (*env)->ExceptionClear(env);
207 string = (*env)->CallObjectMethod(env, exception, get_message_id);
208 if ((*env)->ExceptionCheck(env)) {
209 (*env)->ExceptionClear(env);
216 message = ff_jni_jstring_to_utf_chars(env, string, log_ctx);
217 (*env)->DeleteLocalRef(env, string);
239 (*env)->DeleteLocalRef(env, class_class);
243 (*env)->DeleteLocalRef(env, exception_class);
247 (*env)->DeleteLocalRef(env, string);
253 int ff_jni_exception_check(JNIEnv *env, int log, void *log_ctx)
261 if (!(*(env))->ExceptionCheck((env))) {
266 (*(env))->ExceptionClear((env));
270 exception = (*env)->ExceptionOccurred(env);
271 (*(env))->ExceptionClear((env));
273 if ((ret = ff_jni_exception_get_summary(env, exception, &message, log_ctx)) < 0) {
274 (*env)->DeleteLocalRef(env, exception);
278 (*env)->DeleteLocalRef(env, exception);
286 int ff_jni_init_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx)
300 clazz = (*env)->FindClass(env, jfields_mapping[i].name);
301 if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) {
306 global ? (*env)->NewGlobalRef(env, clazz) : clazz;
309 (*env)->DeleteLocalRef(env, clazz);
321 jfieldID field_id = (*env)->GetFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature);
322 if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) {
330 jfieldID field_id = (*env)->GetStaticFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature);
331 if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) {
339 jmethodID method_id = (*env)->GetMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature);
340 if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) {
348 jmethodID method_id = (*env)->GetStaticMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature);
349 if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) {
369 ff_jni_reset_jfields(env, jfields, jfields_mapping, global, log_ctx);
375 int ff_jni_reset_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx)
389 (*env)->DeleteGlobalRef(env, clazz);
391 (*env)->DeleteLocalRef(env, clazz);