Skip to content

Migrate ViewManagersPropertyCache to Kotlin#56911

Open
cortinico wants to merge 1 commit into
facebook:mainfrom
cortinico:export-D105847022
Open

Migrate ViewManagersPropertyCache to Kotlin#56911
cortinico wants to merge 1 commit into
facebook:mainfrom
cortinico:export-D105847022

Conversation

@cortinico
Copy link
Copy Markdown
Contributor

Summary:
Convert ViewManagersPropertyCache from Java to Kotlin as part of the ongoing React Native Android migration to 100% Kotlin. The class is package-private (now internal) and is only consumed by ViewManagerPropertyUpdater, so there is no public OSS-visible API change. The public PropSetter getters getPropName() / getPropType() are preserved as Kotlin val properties with the same JVM signatures, keeping byte-compatibility with the existing Kotlin caller.

Adjacent changes in this revision:

  • Drop the VIEW_MGR_ARGS / VIEW_MGR_GROUP_ARGS / SHADOW_ARGS / SHADOW_GROUP_ARGS ThreadLocal caches. Their purpose in the Java version was to avoid the per-call Object[] allocation that Method.invoke's varargs would otherwise force; in Kotlin, the spread operator (*args) emits a defensive array copy on every call, so the caches no longer save anything. Calling setter.invoke(viewManager, viewToUpdate, ...) with positional arguments has the same allocation cost and removes the dead complexity.
  • Restore the original non-null parameter contract on getNativePropSettersForShadowNodeClass: the recursion now bottoms out by reading cls.superclass once and only recursing when it is non-null, matching the Java behavior without widening the public/internal API.
  • Add Suppress("DEPRECATION") at the file level since PropSetter.updateShadowNodeProp legitimately consumes the deprecated ReactShadowNode API surface.
  • Remove ViewManagersPropertyCache.java from the ReactNoNewJavaDetector allow-list.

Changelog: [Internal]

Differential Revision: D105847022

Summary:
Convert `ViewManagersPropertyCache` from Java to Kotlin as part of the ongoing React Native Android migration to 100% Kotlin. The class is package-private (now `internal`) and is only consumed by `ViewManagerPropertyUpdater`, so there is no public OSS-visible API change. The public `PropSetter` getters `getPropName()` / `getPropType()` are preserved as Kotlin `val` properties with the same JVM signatures, keeping byte-compatibility with the existing Kotlin caller.

Adjacent changes in this revision:
- Drop the `VIEW_MGR_ARGS` / `VIEW_MGR_GROUP_ARGS` / `SHADOW_ARGS` / `SHADOW_GROUP_ARGS` `ThreadLocal` caches. Their purpose in the Java version was to avoid the per-call `Object[]` allocation that `Method.invoke`'s varargs would otherwise force; in Kotlin, the spread operator (`*args`) emits a defensive array copy on every call, so the caches no longer save anything. Calling `setter.invoke(viewManager, viewToUpdate, ...)` with positional arguments has the same allocation cost and removes the dead complexity.
- Restore the original non-null parameter contract on `getNativePropSettersForShadowNodeClass`: the recursion now bottoms out by reading `cls.superclass` once and only recursing when it is non-null, matching the Java behavior without widening the public/internal API.
- Add `Suppress("DEPRECATION")` at the file level since `PropSetter.updateShadowNodeProp` legitimately consumes the deprecated `ReactShadowNode` API surface.
- Remove `ViewManagersPropertyCache.java` from the `ReactNoNewJavaDetector` allow-list.

Changelog: [Internal]

Differential Revision: D105847022
@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 May 20, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 20, 2026

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

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.

1 participant