From 029c6b9a36e7e8c52737b7ae501b521924161e25 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 14 Feb 2025 13:04:42 -0800 Subject: [PATCH] Introduce internal @LegacyArchitecture annotation (#49443) Summary: This diff introduces an internal annotation called LegacyArchitecture that will be used to document what classes are part of Legacy or new architecture changelog: [internal] internal Reviewed By: cortinico Differential Revision: D69538444 --- .../ReactAndroid/api/ReactAndroid.api | 12 ++++++++++ .../internal/LegacyArchitecture.kt | 24 +++++++++++++++++++ .../internal/LegacyArchitectureLogLevel.kt | 22 +++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitecture.kt create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index d4620d0e6687..6eea80197161 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1830,6 +1830,18 @@ public abstract interface annotation class com/facebook/react/common/annotations public abstract interface annotation class com/facebook/react/common/annotations/VisibleForTesting : java/lang/annotation/Annotation { } +public abstract interface annotation class com/facebook/react/common/annotations/internal/LegacyArchitecture : java/lang/annotation/Annotation { + public abstract fun logLevel ()Lcom/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel; +} + +public final class com/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel : java/lang/Enum { + public static final field ERROR Lcom/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel; + public static final field WARNING Lcom/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel; + public static fun values ()[Lcom/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel; +} + public final class com/facebook/react/common/assets/ReactFontManager { public static final field Companion Lcom/facebook/react/common/assets/ReactFontManager$Companion; public fun ()V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitecture.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitecture.kt new file mode 100644 index 000000000000..351a85ffae32 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitecture.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.common.annotations.internal + +/** + * Annotation to mark classes or functions that are part of the legacy architecture. + * + * This annotation is used to indicate that the annotated class or function is part of the legacy + * architecture. The `logLevel` parameter can be used to specify the level of logging that should be + * applied when the annotated element is used. + * + * @property logLevel The logging level to be used for the annotated element. Defaults to + * `LegacyArchitectureLogLevel.WARNING`. + */ +@Retention(AnnotationRetention.SOURCE) +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +public annotation class LegacyArchitecture( + val logLevel: LegacyArchitectureLogLevel = LegacyArchitectureLogLevel.WARNING +) {} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel.kt new file mode 100644 index 000000000000..a28508b0f357 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitectureLogLevel.kt @@ -0,0 +1,22 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.common.annotations.internal + +/** + * Enum class representing the log levels for classes annotated with @LegacyArcture annoation. + * + * It provides two levels of logging: + * - WARNING: Indicates a warning signal will be logged if the underlying class is used when the new + * architecture is enabled. + * - ERROR: : Indicates an error signal will be logged if the underlying class is used when the new + * architecture is enabled. + */ +public enum class LegacyArchitectureLogLevel { + WARNING, + ERROR +}