Skip to content

Remove JavaMethodWrapper and decouple JavaModuleWrapper from legacy invocation (#56201)#56201

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

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

Conversation

@mdvacca
Copy link
Copy Markdown
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

@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
Copy Markdown

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
Copy Markdown
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.

@meta-codesync meta-codesync bot changed the title Remove JavaMethodWrapper and decouple JavaModuleWrapper from legacy invocation Remove JavaMethodWrapper and decouple JavaModuleWrapper from legacy invocation (#56201) Apr 6, 2026
mdvacca added a commit to mdvacca/react-native that referenced this pull request Apr 6, 2026
…nvocation (facebook#56201)

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
@mdvacca mdvacca force-pushed the export-D97387121 branch from 8420ecc to 43fad36 Compare April 6, 2026 16:22
mdvacca added a commit to mdvacca/react-native that referenced this pull request Apr 6, 2026
…nvocation (facebook#56201)

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 (facebook#56201)

Summary:
Pull Request resolved: facebook#56201

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
@mdvacca mdvacca force-pushed the export-D97387121 branch from 43fad36 to 3ca3cb7 Compare April 6, 2026 16:25
mdvacca added a commit to mdvacca/react-native that referenced this pull request Apr 6, 2026
…nvocation (facebook#56201)

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.


Changelog: [Internal] internal

Reviewed By: cortinico, javache

Differential Revision: D97387121
@meta-codesync meta-codesync bot closed this in a0175d4 Apr 6, 2026
@facebook-github-tools facebook-github-tools bot added the Merged This PR has been merged. label Apr 6, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 6, 2026

This pull request has been merged in a0175d4.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @mdvacca in a0175d4

When will my fix make it into a release? | How to file a pick request?

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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants