Migrate ViewManagersPropertyCache to Kotlin#56911
Open
cortinico wants to merge 1 commit into
Open
Conversation
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
|
@cortinico has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105847022. |
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:
Convert
ViewManagersPropertyCachefrom Java to Kotlin as part of the ongoing React Native Android migration to 100% Kotlin. The class is package-private (nowinternal) and is only consumed byViewManagerPropertyUpdater, so there is no public OSS-visible API change. The publicPropSettergettersgetPropName()/getPropType()are preserved as Kotlinvalproperties with the same JVM signatures, keeping byte-compatibility with the existing Kotlin caller.Adjacent changes in this revision:
VIEW_MGR_ARGS/VIEW_MGR_GROUP_ARGS/SHADOW_ARGS/SHADOW_GROUP_ARGSThreadLocalcaches. Their purpose in the Java version was to avoid the per-callObject[]allocation thatMethod.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. Callingsetter.invoke(viewManager, viewToUpdate, ...)with positional arguments has the same allocation cost and removes the dead complexity.getNativePropSettersForShadowNodeClass: the recursion now bottoms out by readingcls.superclassonce and only recursing when it is non-null, matching the Java behavior without widening the public/internal API.Suppress("DEPRECATION")at the file level sincePropSetter.updateShadowNodeProplegitimately consumes the deprecatedReactShadowNodeAPI surface.ViewManagersPropertyCache.javafrom theReactNoNewJavaDetectorallow-list.Changelog: [Internal]
Differential Revision: D105847022