diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index b2978653b9b1..2b1a65526f19 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -59,7 +59,6 @@ import com.facebook.react.bridge.NativeModuleRegistry; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; -import com.facebook.react.bridge.ReactCxxErrorHandler; import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.bridge.ReactNoCrashSoftException; @@ -75,7 +74,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitecture; import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel; import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; -import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.devsupport.DevSupportManagerFactory; import com.facebook.react.devsupport.ReactInstanceDevHelper; import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; @@ -107,7 +105,6 @@ import com.facebook.soloader.SoLoader; import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -304,8 +301,6 @@ public static ReactInstanceManagerBuilder builder() { mDevSupportManager.startInspector(); } - registerCxxErrorHandlerFunc(); - // Using `if (true)` just to prevent tests / lint errors. if (true) { // Legacy architecture of React Native is deprecated and can't be initialized anymore. @@ -402,24 +397,6 @@ public void handleCxxError(Exception e) { mDevSupportManager.handleException(e); } - private void registerCxxErrorHandlerFunc() { - if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) { - Class[] parameterTypes = new Class[1]; - parameterTypes[0] = Exception.class; - Method handleCxxErrorFunc = null; - try { - handleCxxErrorFunc = ReactInstanceManager.class.getMethod("handleCxxError", parameterTypes); - } catch (NoSuchMethodException e) { - FLog.e("ReactInstanceHolder", "Failed to set cxx error handler function", e); - } - ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc); - } - } - - private void unregisterCxxErrorHandlerFunc() { - ReactCxxErrorHandler.setHandleErrorFunc(null, null); - } - static void initializeSoLoaderIfNecessary(Context applicationContext) { // Call SoLoader.initialize here, this is required for apps that does not use exopackage and // does not use SoLoader for loading other native code except from the one used by React Native @@ -799,7 +776,6 @@ public void destroy() { moveToBeforeCreateLifecycleState(); mMemoryPressureRouter.destroy(mApplicationContext); - unregisterCxxErrorHandlerFunc(); mCreateReactContextThread = null; synchronized (mAttachedReactRoots) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.kt deleted file mode 100644 index 7e817e70ed7a..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.bridge - -import com.facebook.common.logging.FLog -import com.facebook.proguard.annotations.DoNotStrip -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger -import java.lang.reflect.Method - -@DoNotStrip -@LegacyArchitecture -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -internal object ReactCxxErrorHandler { - init { - LegacyArchitectureLogger.assertLegacyArchitecture( - "ReactCxxErrorHandler", - LegacyArchitectureLogLevel.WARNING, - ) - } - - private var handleErrorFunc: Method? = null - private var handlerObject: Any? = null - - @DoNotStrip - @JvmStatic - fun setHandleErrorFunc(handlerObject: Any?, handleErrorFunc: Method?) { - this.handlerObject = handlerObject - this.handleErrorFunc = handleErrorFunc - } - - @DoNotStrip - @JvmStatic - // For use from within the C++ JReactCxxErrorHandler - private fun handleError(message: String) { - handleErrorFunc?.let { - try { - val parameters = arrayOf(Exception(message)) - it.invoke(handlerObject, parameters) - } catch (e: Exception) { - FLog.e("ReactCxxErrorHandler", "Failed to invoke error handler function", e) - } - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CMakeLists.txt index 1fb809ef48f3..1e17ddb93db1 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CMakeLists.txt @@ -55,7 +55,6 @@ add_library( InspectorNetworkRequestListener.cpp JExecutor.cpp JMessageQueueThread.cpp - JReactCxxErrorHandler.cpp JReactSoftExceptionLogger.cpp JRuntimeExecutor.cpp JRuntimeScheduler.cpp diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp index 1fd3c87395a6..99104790ae29 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp @@ -30,7 +30,6 @@ #include -#include "JReactCxxErrorHandler.h" #include "JReactSoftExceptionLogger.h" #include "JavaScriptExecutorHolder.h" #include "JniJSModulesUnbundle.h" @@ -147,7 +146,6 @@ void log(ReactNativeLogLevel level, const char* message) { break; case ReactNativeLogLevelError: LOG(ERROR) << message; - JReactCxxErrorHandler::handleError(message); break; case ReactNativeLogLevelFatal: LOG(FATAL) << message; diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp deleted file mode 100644 index 46eb39332ef7..000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "JReactCxxErrorHandler.h" - -#include - -using namespace facebook::react; - -void JReactCxxErrorHandler::handleError(std::string message) { - static const auto handleError = - javaClassStatic()->getStaticMethod( - "handleError"); - - return handleError(javaClassStatic(), std::move(message)); -} diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h deleted file mode 100644 index b50a0580ae2d..000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -namespace facebook::react { - -class JReactCxxErrorHandler : public jni::JavaClass { - public: - static constexpr const char *kJavaDescriptor = "Lcom/facebook/react/bridge/ReactCxxErrorHandler;"; - - static void handleError(std::string message); -}; - -} // namespace facebook::react diff --git a/scripts/cxx-api/ReactNativeCPP.api b/scripts/cxx-api/ReactNativeCPP.api index c4b1c6277764..e9747933f40e 100644 --- a/scripts/cxx-api/ReactNativeCPP.api +++ b/scripts/cxx-api/ReactNativeCPP.api @@ -7182,16 +7182,6 @@ class JMessageQueueThread : public MessageQueueThread { }; } // namespace facebook::react -/// @src {packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h}: -namespace facebook::react { -class JReactCxxErrorHandler : public jni::JavaClass { - public: - static constexpr const char* kJavaDescriptor = - "Lcom/facebook/react/bridge/ReactCxxErrorHandler;"; - static void handleError(std::string message); -}; -} // namespace facebook::react - /// @src {packages/react-native/ReactAndroid/src/main/jni/react/jni/JReactMarker.h}: namespace facebook::react { class JReactMarker : public facebook::jni::JavaClass {