Skip to content

Comments

#55350-RuntimeException: Unrecognized type: class java.lang.Float for…#55666

Open
aswinandro wants to merge 1 commit intofacebook:mainfrom
aswinandro:origin/#55350-FIX-RuntimeException
Open

#55350-RuntimeException: Unrecognized type: class java.lang.Float for…#55666
aswinandro wants to merge 1 commit intofacebook:mainfrom
aswinandro:origin/#55350-FIX-RuntimeException

Conversation

@aswinandro
Copy link
Contributor

@aswinandro aswinandro commented Feb 21, 2026

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.

…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".
@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 Feb 21, 2026
@aswinandro aswinandro closed this Feb 21, 2026
@aswinandro aswinandro reopened this Feb 21, 2026
@aswinandro aswinandro closed this Feb 21, 2026
@aswinandro aswinandro reopened this Feb 21, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 21, 2026
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants