Fix on_fatal_error in Java example.

GitOrigin-RevId: 09b6463518e391a70918685205236ffa59a9a121
This commit is contained in:
levlam 2020-10-11 14:20:26 +03:00
parent 4ad90cecc6
commit 78b19d949f

View File

@ -103,8 +103,11 @@ static jclass log_class;
static void on_fatal_error(const char *error_message) { static void on_fatal_error(const char *error_message) {
auto env = td::jni::get_jni_env(java_vm, JAVA_VERSION); auto env = td::jni::get_jni_env(java_vm, JAVA_VERSION);
if (env == nullptr) {
return;
}
jmethodID on_fatal_error_method = env->GetStaticMethodID(log_class, "onFatalError", "(Ljava/lang/String;)V"); jmethodID on_fatal_error_method = env->GetStaticMethodID(log_class, "onFatalError", "(Ljava/lang/String;)V");
if (env && on_fatal_error_method) { if (on_fatal_error_method) {
jstring error_str = td::jni::to_jstring(env.get(), error_message); jstring error_str = td::jni::to_jstring(env.get(), error_message);
env->CallStaticVoidMethod(log_class, on_fatal_error_method, error_str); env->CallStaticVoidMethod(log_class, on_fatal_error_method, error_str);
if (error_str) { if (error_str) {