From 163d553ba2ef4ab23bdca8abf9be323beb67c855 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 26 Sep 2025 14:07:25 -0700 Subject: [PATCH] Delete NoSuchNativeViewException (#53946) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53946 NoSuchNativeViewException is legacy architecture and unused, let's delete it changelog: [internal] internal Reviewed By: alanleedev Differential Revision: D83186872 fbshipit-source-id: cbd3b2f537673745e634d0bfc8717fc93f1c0c5f --- .../uimanager/NativeViewHierarchyManager.java | 6 ++-- .../uimanager/NoSuchNativeViewException.kt | 34 ------------------- .../react/uimanager/UIViewOperationQueue.java | 4 +-- 3 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index af824f92bb0..2063e79fc67 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -706,14 +706,14 @@ public class NativeViewHierarchyManager { UiThreadUtil.assertOnUiThread(); View v = mTagsToViews.get(tag); if (v == null) { - throw new NoSuchNativeViewException("No native view for " + tag + " currently exists"); + throw new IllegalViewOperationException("No native view for " + tag + " currently exists"); } View rootView = (View) RootViewUtil.getRootView(v); // It is possible that the RootView can't be found because this view is no longer on the screen // and has been removed by clipping if (rootView == null) { - throw new NoSuchNativeViewException("Native view " + tag + " is no longer on screen"); + throw new IllegalViewOperationException("Native view " + tag + " is no longer on screen"); } computeBoundingBox(rootView, outputBuffer); int rootX = outputBuffer[0]; @@ -773,7 +773,7 @@ public class NativeViewHierarchyManager { UiThreadUtil.assertOnUiThread(); View v = mTagsToViews.get(tag); if (v == null) { - throw new NoSuchNativeViewException("No native view for " + tag + " currently exists"); + throw new IllegalViewOperationException("No native view for " + tag + " currently exists"); } v.getLocationOnScreen(outputBuffer); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.kt deleted file mode 100644 index 0d128e43976..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.kt +++ /dev/null @@ -1,34 +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.uimanager - -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger - -/** - * Exception thrown when a class tries to access a native view by a tag that has no native view - * associated with it. - */ -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -internal class NoSuchNativeViewException(detailMessage: String) : - IllegalViewOperationException(detailMessage) { - - private companion object { - init { - LegacyArchitectureLogger.assertLegacyArchitecture( - "NoSuchNativeViewException", - LegacyArchitectureLogLevel.ERROR, - ) - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 339f94da9ce..6745ca88c5f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -418,7 +418,7 @@ public class UIViewOperationQueue { public void execute() { try { mNativeViewHierarchyManager.measure(mReactTag, mMeasureBuffer); - } catch (NoSuchNativeViewException e) { + } catch (IllegalViewOperationException e) { // Invoke with no args to signal failure and to allow JS to clean up the callback // handle. mCallback.invoke(); @@ -448,7 +448,7 @@ public class UIViewOperationQueue { public void execute() { try { mNativeViewHierarchyManager.measureInWindow(mReactTag, mMeasureBuffer); - } catch (NoSuchNativeViewException e) { + } catch (IllegalViewOperationException e) { // Invoke with no args to signal failure and to allow JS to clean up the callback // handle. mCallback.invoke();