Skip to content

Commit

Permalink
Annotate HybridData with DoNotStrip (#39342)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39342

Annotate HybridData with DoNotStrip

The stack of diffs aims to introduce new features and deprecate old ones in the React Native Android architecture. The main goal is to make the architecture more stable and easier to use for developers. The changes include marking ReactPackage as NullSafe, introducing the new getModule method, introducing the WillBeDeprecatedInNewArchitecture annotation, deprecating createNativeModules and marking getModule as UnstableReactNativeAPI, and fixing a lint warning in MainReactPackage.

# This diff
This diff is adding the annotation `DoNotStrip` to the `HybridData` field in the `NativeMethodCallInvokerHolderImpl` and `CallInvokerHolderImpl` classes. This is to prevent the Android ProGuard optimizer from stripping the `HybridData` field, which is necessary for the proper functioning of the TurboModule system in React Native. Additionally, the `BUCK` file for the `core` module is updated to include the `androidx:annotation` and `com.facebook.proguard.annotations:annotations` dependencies.

changelog: [intenral] internal# Context

Reviewed By: cortinico

Differential Revision: D49077065

fbshipit-source-id: cb36c0a11bdb8f5f0f4eaa7db1f0c9dcb3be2341
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 14, 2023
1 parent fdae17d commit a629ac4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.turbomodule.core;

import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;

/**
Expand All @@ -16,7 +17,8 @@
* pass it from CatalystInstance, through Java, to TurboModuleManager::initHybrid.
*/
public class CallInvokerHolderImpl implements CallInvokerHolder {
private final HybridData mHybridData;

@DoNotStrip private final HybridData mHybridData;

static {
NativeModuleSoLoader.maybeLoadSoLibrary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.turbomodule.core;

import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder;

/**
Expand All @@ -18,7 +19,7 @@
*/
public class NativeMethodCallInvokerHolderImpl implements NativeMethodCallInvokerHolder {

private final HybridData mHybridData;
@DoNotStrip private final HybridData mHybridData;

static {
NativeModuleSoLoader.maybeLoadSoLibrary();
Expand Down

0 comments on commit a629ac4

Please sign in to comment.