Skip to content

Commit 95e0b5e

Browse files
alanleedevmeta-codesync[bot]
authored andcommitted
Add Android 17 safety comment for JNI-written static field (#56442)
Summary: Pull Request resolved: #56442 AppearanceModule.invalidatePlatformColorCache is set from native via JNI (configurePlatformColorCacheInvalidationHook.cpp). Android 17 crashes if JNI modifies a static final field. Since Kotlin `val` compiles to static final, this field must remain `var`. Added a comment to prevent accidental refactoring. See https://developer.android.com/about/versions/17/behavior-changes-17#static-final-fields Changelog: [Internal] ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: react_native Differential Revision: D100831802 fbshipit-source-id: ab52b01337e8dd90f8db2766afd00fbaa4a41018
1 parent 0517fb5 commit 95e0b5e

File tree

1 file changed

+3
-0
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance

1 file changed

+3
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ constructor(
137137
public const val NAME: String = NativeAppearanceSpec.NAME
138138
private const val APPEARANCE_CHANGED_EVENT_NAME = "appearanceChanged"
139139

140+
// Must remain `var` (not `val`) — this field is set from JNI in
141+
// configurePlatformColorCacheInvalidationHook.cpp. Android 17+ crashes
142+
// if JNI modifies a static final field (which `val` compiles to).
140143
@DoNotStrip private var invalidatePlatformColorCache: Runnable? = null
141144
}
142145
}

0 commit comments

Comments
 (0)