in androidLibs/fbjni/cxx/fbjni/fbjni.cpp [18:53]
jint initialize(JavaVM* vm, std::function<void()>&& init_fn) noexcept {
// TODO (t7832883): DTRT when we have exception pointers
static auto error_msg = std::string{"Failed to initialize fbjni"};
static bool error_occured = [vm] {
bool retVal = false;
try {
Environment::initialize(vm);
} catch (std::exception& ex) {
retVal = true;
try {
error_msg = std::string{"Failed to initialize fbjni: "} + ex.what();
} catch (...) {
// Ignore, we already have a fall back message
}
} catch (...) {
retVal = true;
}
return retVal;
}();
try {
if (error_occured) {
throw std::runtime_error(error_msg);
}
init_fn();
} catch (const std::exception& e) {
FBJNI_LOGE("error %s", e.what());
translatePendingCppExceptionToJavaException();
} catch (...) {
translatePendingCppExceptionToJavaException();
// So Java will handle the translated exception, fall through and
// return a good version number.
}
return JNI_VERSION_1_6;
}