#55350-RuntimeException: Unrecognized type: class java.lang.Float for…#55666
Open
aswinandro wants to merge 1 commit intofacebook:mainfrom
Open
#55350-RuntimeException: Unrecognized type: class java.lang.Float for…#55666aswinandro wants to merge 1 commit intofacebook:mainfrom
aswinandro wants to merge 1 commit intofacebook:mainfrom
Conversation
…loat for method: SomeViewManager#setProp Introduce BoxedFloatPropSetter in ViewManagersPropertyCache to support boxed Float props (converts incoming Double values to float and preserves null). Update factory logic to return the new setter for Float.class and handle ReactPropGroup cases. Add tests in ReactPropAnnotationSetterTest for boxed float prop and grouped props, and update ReactPropConstantsTest to include boxed float mappings to "number".
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.
Fix Android runtime crash when a @ReactProp setter uses nullable Float (java.lang.Float / Float?) in fallback property reflection.
ViewManagersPropertyCache supported primitive float but not boxed Float, which caused:
RuntimeException: Unrecognized type: class java.lang.Float for method ...
during native prop extraction. This can happen even for codegen/Fabric view managers because native props metadata still goes through the fallback reflection path.
This PR adds boxed float support for both @ReactProp and @ReactPropGroup.
Changelog:
[ANDROID] [FIXED] - Add nullable Float (java.lang.Float) support in @ReactProp/@ReactPropGroup fallback setters to prevent runtime crash in ViewManagersPropertyCache.
Test Plan:
Added unit coverage in ReactPropAnnotationSetterTest.kt:
boxedFloatProp verifies Double -> Float conversion and null passthrough.
boxedFloatGroupProp* verifies grouped nullable float behavior and null passthrough.
Added constants coverage in ReactPropConstantsTest.kt:
Verifies boxed float props are exported as "number".
Attempted to run targeted tests:
gradlew :packages:react-native:ReactAndroid:test --tests com.facebook.react.uimanager.ReactPropAnnotationSetterTest --tests com.facebook.react.uimanager.ReactPropConstantsTest
In this environment, Gradle fails before test execution due to repo settings autolinking (settings.gradle.kts line 42: Process 'command 'cmd'' finished with non-zero exit value 1).
Code compiles logically and test additions are scoped to the changed behavior.