Skip to content

Commit accd1c8

Browse files
RSNarafacebook-github-bot
authored andcommitted
both: Deprecate c++ legacy core classes
Summary: Let's deprecate all the classes that aren't used by interop or the new architecture. Changelog: [General][Deprecated] - Deprecate all the c++ classes not used by interop, or the new architecture. Differential Revision: D80575767
1 parent 028e582 commit accd1c8

25 files changed

+101
-35
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ static void installBindings(jsi::Runtime& runtime) {
4444
react::bindNativeLogger(runtime, &reactAndroidLoggingHook);
4545
}
4646

47-
class HermesExecutorHolder
47+
class [[deprecated(
48+
"This API will be removed along with the legacy architecture.")]] HermesExecutorHolder
4849
: public jni::HybridClass<HermesExecutorHolder, JavaScriptExecutorHolder> {
4950
public:
5051
static constexpr auto kJavaDescriptor =
@@ -110,6 +111,10 @@ class HermesExecutorHolder
110111
} // namespace facebook::react
111112

112113
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
113-
return facebook::jni::initialize(
114-
vm, [] { facebook::react::HermesExecutorHolder::registerNatives(); });
114+
return facebook::jni::initialize(vm, [] {
115+
#pragma clang diagnostic push
116+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
117+
facebook::react::HermesExecutorHolder::registerNatives();
118+
#pragma clang diagnostic pop
119+
});
115120
}

packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ namespace facebook::react {
4545

4646
namespace {
4747

48-
class InstanceCallbackImpl : public InstanceCallback {
48+
class [[deprecated(
49+
"This API will be removed along with the legacy architecture.")]] InstanceCallbackImpl
50+
: public InstanceCallback {
4951
public:
5052
explicit InstanceCallbackImpl(alias_ref<JInstanceCallback::javaobject> jobj)
5153
: jobj_(make_global(jobj)) {}

packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ class Instance;
2929
class JavaScriptExecutorHolder;
3030
class NativeArray;
3131

32-
struct JInstanceCallback : public jni::JavaClass<JInstanceCallback> {
32+
struct [[deprecated(
33+
"This API will be removed along with the legacy architecture.")]] JInstanceCallback
34+
: public jni::JavaClass<JInstanceCallback> {
3335
static constexpr auto kJavaDescriptor =
3436
"Lcom/facebook/react/bridge/CatalystInstanceImpl$InstanceCallback;";
3537
};
3638

37-
class CatalystInstanceImpl : public jni::HybridClass<CatalystInstanceImpl> {
39+
class [[deprecated(
40+
"This API will be removed along with the legacy architecture.")]] CatalystInstanceImpl
41+
: public jni::HybridClass<CatalystInstanceImpl> {
3842
public:
3943
static constexpr auto kJavaDescriptor =
4044
"Lcom/facebook/react/bridge/CatalystInstanceImpl;";

packages/react-native/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ namespace facebook::react {
2020
class Instance;
2121
class MessageQueueThread;
2222

23-
struct JMethodDescriptor : public jni::JavaClass<JMethodDescriptor> {
23+
struct [[deprecated(
24+
"This API will be removed along with the legacy architecture.")]] JMethodDescriptor
25+
: public jni::JavaClass<JMethodDescriptor> {
2426
static constexpr auto kJavaDescriptor =
2527
"Lcom/facebook/react/bridge/JavaModuleWrapper$MethodDescriptor;";
2628

@@ -30,7 +32,9 @@ struct JMethodDescriptor : public jni::JavaClass<JMethodDescriptor> {
3032
std::string getType() const;
3133
};
3234

33-
struct JavaModuleWrapper : jni::JavaClass<JavaModuleWrapper> {
35+
struct [[deprecated(
36+
"This API will be removed along with the legacy architecture.")]] JavaModuleWrapper
37+
: jni::JavaClass<JavaModuleWrapper> {
3438
static constexpr auto kJavaDescriptor =
3539
"Lcom/facebook/react/bridge/JavaModuleWrapper;";
3640

@@ -59,7 +63,9 @@ struct JavaModuleWrapper : jni::JavaClass<JavaModuleWrapper> {
5963
}
6064
};
6165

62-
class JavaNativeModule : public NativeModule {
66+
class [[deprecated(
67+
"This API will be removed along with the legacy architecture.")]] JavaNativeModule
68+
: public NativeModule {
6369
public:
6470
JavaNativeModule(
6571
std::weak_ptr<Instance> instance,

packages/react-native/ReactAndroid/src/main/jni/react/jni/JavaScriptExecutorHolder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
namespace facebook::react {
1616

17-
class JavaScriptExecutorHolder
17+
class [[deprecated(
18+
"This API will be removed along with the legacy architecture.")]] JavaScriptExecutorHolder
1819
: public jni::HybridClass<JavaScriptExecutorHolder> {
1920
public:
2021
static constexpr auto kJavaDescriptor =

packages/react-native/ReactAndroid/src/main/jni/react/jni/JniJSModulesUnbundle.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
namespace facebook::react {
1818

19-
class JniJSModulesUnbundle : public JSModulesUnbundle {
19+
class [[deprecated(
20+
"This API will be removed along with the legacy architecture.")]] JniJSModulesUnbundle
21+
: public JSModulesUnbundle {
2022
/**
2123
* This implementation reads modules as single file from the assets of an apk.
2224
*/

packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ local_ref<JCxxCallbackImpl::jhybridobject> extractCallback(
8080
if (value.isNull()) {
8181
return {nullptr};
8282
} else {
83+
#pragma clang diagnostic push
84+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
8385
return JCxxCallbackImpl::newObjectCxxArgs(makeCallback(instance, value));
86+
#pragma clang diagnostic pop
8487
}
8588
}
8689

packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ namespace facebook::react {
1919

2020
class Instance;
2121

22-
struct JReflectMethod : public jni::JavaClass<JReflectMethod> {
22+
struct [[deprecated(
23+
"This API will be removed along with the legacy architecture.")]] JReflectMethod
24+
: public jni::JavaClass<JReflectMethod> {
2325
static constexpr auto kJavaDescriptor = "Ljava/lang/reflect/Method;";
2426

2527
jmethodID getMethodID() {
@@ -29,12 +31,15 @@ struct JReflectMethod : public jni::JavaClass<JReflectMethod> {
2931
}
3032
};
3133

32-
struct JBaseJavaModule : public jni::JavaClass<JBaseJavaModule> {
34+
struct [[deprecated(
35+
"This API will be removed along with the legacy architecture.")]] JBaseJavaModule
36+
: public jni::JavaClass<JBaseJavaModule> {
3337
static constexpr auto kJavaDescriptor =
3438
"Lcom/facebook/react/bridge/BaseJavaModule;";
3539
};
3640

37-
class MethodInvoker {
41+
class [[deprecated(
42+
"This API will be removed along with the legacy architecture.")]] MethodInvoker {
3843
public:
3944
MethodInvoker(
4045
jni::alias_ref<JReflectMethod::javaobject> method,

packages/react-native/ReactAndroid/src/main/jni/react/jni/ModuleRegistryBuilder.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ namespace facebook::react {
2020

2121
class MessageQueueThread;
2222

23-
class ModuleHolder : public jni::JavaClass<ModuleHolder> {
23+
class [[deprecated(
24+
"This API will be removed along with the legacy architecture.")]] ModuleHolder
25+
: public jni::JavaClass<ModuleHolder> {
2426
public:
2527
static auto constexpr kJavaDescriptor =
2628
"Lcom/facebook/react/bridge/ModuleHolder;";
@@ -30,6 +32,7 @@ class ModuleHolder : public jni::JavaClass<ModuleHolder> {
3032
const std::string& moduleName) const;
3133
};
3234

35+
[[deprecated("This API will be removed along with the legacy architecture.")]]
3336
std::vector<std::unique_ptr<NativeModule>> buildNativeModuleList(
3437
std::weak_ptr<Instance> winstance,
3538
jni::alias_ref<jni::JCollection<JavaModuleWrapper::javaobject>::javaobject>

packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
3737
FLAGS_minloglevel = 0;
3838
#endif
3939
#ifndef RCT_FIT_RM_OLD_RUNTIME
40+
#pragma clang diagnostic push
41+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
4042
CatalystInstanceImpl::registerNatives();
43+
#pragma clang diagnostic pop
4144
#endif
4245
CxxModuleWrapperBase::registerNatives();
4346
ReactInstanceManagerInspectorTarget::registerNatives();

0 commit comments

Comments
 (0)