return;
}
ScopedLocalRef peer(tlsPtr_.jni_env, soa.AddLocalReference(tlsPtr_.opeer));
ScopedThreadStateChange tsc(this, kNative);
// Get and clear the exception.
ScopedLocalRef exception(tlsPtr_.jni_env, tlsPtr_.jni_env->ExceptionOccurred());
tlsPtr_.jni_env->ExceptionClear();
// 调用当前线程的dispatchUncaughtException方法进行分发
// Call the Thread instance’s dispatchUncaughtException(Throwable)
tlsPtr_.jni_env->CallVoidMethod(peer.get(),
WellKnownClasses::java_lang_Thread_dispatchUncaughtException,
exception.get());
// If the dispatchUncaughtException threw, clear that exception too.
tlsPtr_.jni_env->ExceptionClear();
}
所以,Thread的dispatchUncaughtException
负责处理异常的分发逻辑。
2.2.1 分发过程
- 首先处理
setUncaughtExceptionPreHandler()
方法注册的异常处理Handler —— 这里的是LoggingHandler
,负责记录日志(默认,不可修改过)