Skip to content

Remove JavaMethodWrapper and decouple JavaModuleWrapper from legacy invocation#56201

Open
mdvacca wants to merge 1 commit intofacebook:mainfrom
mdvacca:export-D97387121
Open

Remove JavaMethodWrapper and decouple JavaModuleWrapper from legacy invocation#56201
mdvacca wants to merge 1 commit intofacebook:mainfrom
mdvacca:export-D97387121

Conversation

@mdvacca
Copy link
Contributor

@mdvacca mdvacca commented Mar 23, 2026

Summary:
JavaMethodWrapper is a legacy architecture class that wraps ReactMethod-annotated
Java methods via reflection for the bridge-based NativeModule invocation path.

When ReactNativeFeatureFlags.useTurboModuleInterop is enabled (the new architecture),
this class is completely bypassed — the TurboModule interop layer uses
JavaInteropTurboModule (C++) with direct JNI invocation via
JavaTurboModule::invokeJavaMethod(), which converts JSI values to JNI arguments
directly in C++ without any Java-side reflection.

This diff:

  • Deletes JavaMethodWrapper.kt (only instantiated from JavaModuleWrapper.findMethods())
  • Deletes BaseJavaModuleTest.kt (test that exercised JavaMethodWrapper)
  • Removes the NativeMethod interface from JavaModuleWrapper (only implemented by JavaMethodWrapper)
  • Rewrites JavaModuleWrapper.findMethods() to compute method type inline without JavaMethodWrapper
  • Changes JavaModuleWrapper.invoke() to throw UnsupportedOperationException
  • Sets md.signature to empty string for sync methods to prevent C++ null deref

The JavaModuleWrapper class shell is kept because it is still referenced from C++ JNI
(JavaModuleWrapper.cpp) and NativeModuleRegistry. Full removal is planned as follow-up.

Reviewed By: cortinico, javache

Differential Revision: D97387121

…nvocation

Summary:
JavaMethodWrapper is a legacy architecture class that wraps ReactMethod-annotated
Java methods via reflection for the bridge-based NativeModule invocation path.

When ReactNativeFeatureFlags.useTurboModuleInterop is enabled (the new architecture),
this class is completely bypassed — the TurboModule interop layer uses
JavaInteropTurboModule (C++) with direct JNI invocation via
JavaTurboModule::invokeJavaMethod(), which converts JSI values to JNI arguments
directly in C++ without any Java-side reflection.

This diff:
- Deletes JavaMethodWrapper.kt (only instantiated from JavaModuleWrapper.findMethods())
- Deletes BaseJavaModuleTest.kt (test that exercised JavaMethodWrapper)
- Removes the NativeMethod interface from JavaModuleWrapper (only implemented by JavaMethodWrapper)
- Rewrites JavaModuleWrapper.findMethods() to compute method type inline without JavaMethodWrapper
- Changes JavaModuleWrapper.invoke() to throw UnsupportedOperationException
- Sets md.signature to empty string for sync methods to prevent C++ null deref

The JavaModuleWrapper class shell is kept because it is still referenced from C++ JNI
(JavaModuleWrapper.cpp) and NativeModuleRegistry. Full removal is planned as follow-up.

Reviewed By: cortinico, javache

Differential Revision: D97387121
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 23, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 23, 2026

@mdvacca has exported this pull request. If you are a Meta employee, you can view the originating Diff in D97387121.

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants