Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tomekzaw
marked this pull request as ready for review
October 30, 2026 22:05
javache
reviewed
Oct 30, 2026
Comment on lines
+532
to
+540
| static const auto jArguments = | ||
| jni::findClassStatic("com/facebook/react/bridge/Arguments"); | ||
| static jmethodID jMakeNativeMap = env->GetStaticMethodID( | ||
| jArguments, | ||
| jArguments.get(), | ||
| "makeNativeMap", | ||
| "(Ljava/util/Map;)Lcom/facebook/react/bridge/WritableNativeMap;"); | ||
| auto constants = env->CallStaticObjectMethod(jArguments, jMakeNativeMap, arg); | ||
| auto jResult = jni::adopt_local(constants); | ||
| auto result = jni::static_ref_cast<NativeMap::jhybridobject>(jResult); | ||
| return jsi::valueFromDynamic(rt, result->cthis()->consume()); | ||
| return jni::adopt_local( | ||
| static_cast<NativeMap::jhybridobject>( | ||
| env->CallStaticObjectMethod(jArguments.get(), jMakeNativeMap, arg))); |
Contributor
There was a problem hiding this comment.
Let's migrate this to fbjni, so we get the normal error handling.
Contributor
Author
There was a problem hiding this comment.
Done in abae08e. Arguments.makeNativeMap() is now called through an fbjni JavaClass, so a value it can't convert throws a JniException and becomes a JS error.
javache
requested changes
Oct 30, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
JavaTurboModuleconverts a module'sgetConstants()result withArguments.makeNativeMap(). That throwsIllegalArgumentExceptionfor values it can't convert, such as aDateor aUri. The result wasn't checked, so the null map was used with the Java exception still pending, and ART aborted the app withJNI DETECTED ERROR IN APPLICATION: obj == null.This change:
Arguments.makeNativeMap()through an fbjniJavaClass, so a value it can't convert throws through fbjni's usual error handling and becomes a JS error.ArgumentsandmakeNativeMaponce, instead of callingFindClassand leaving its local reference behind on everygetConstants()call.Changelog:
[ANDROID] [FIXED] - Throw a JS error instead of crashing when a TurboModule's constants contain a value that can't be converted
Test Plan:
Release RNTester (
./gradlew :packages:rn-tester:android:app:assembleRelease -PreactNativeArchitectures=arm64-v8a) with these temporary, uncommitted changes:SampleTurboModuleadds ajava.util.Dateconstant when asked to.getConstants().SampleTurboModulecan't initialize in a minified build, which is a separate issue.On a Galaxy A16 (Android 16):
maingetConstants()with aDateconstantJNI DETECTED ERROR IN APPLICATION: obj == null, fromGetObjectFieldinJavaTurboModule::invokeJavaMethodException in HostFunction: java.lang.IllegalArgumentException: Could not convert class java.util.Date, followed by the Java stack tracegetConstants()with valid constants{"const3":"something","const1":true,"const2":1080}Not run: an automated test.
JavaTurboModulehas no host-side tests, and Fantom doesn't load Java modules.🤖 Generated with Claude Code