1 /* 2 * Copyright 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.annotation.keep 18 19 /** 20 * Indicates code which is accessed by references from outside of the application code directly, 21 * such as via JNI, reflection, or instantiation from platform framework code. 22 * 23 * NOTE: This keep rule is unconditional, meaning that the annotated class, method, or field will 24 * always be preserved in the final application even if, for example, the surrounding code is never 25 * used. 26 * 27 * If reflection or JNI access occurs inside the application, instead prefer the 28 * `@GenerateKeepFor***` annotations, as they will keep conditionally, rather than unconditionally 29 * as this annotation does. 30 * 31 * @see GenerateKeepForConstructor 32 * @see GenerateKeepForMethod 33 * @see GenerateKeepForField 34 */ 35 @Retention(AnnotationRetention.BINARY) 36 @Target( 37 AnnotationTarget.CLASS, 38 AnnotationTarget.FIELD, 39 AnnotationTarget.FUNCTION, 40 AnnotationTarget.CONSTRUCTOR, 41 ) 42 public annotation class GenerateUnconditionalKeep( 43 /** 44 * Should the name be preserved. 45 * 46 * Generally this is true if the reference is external, but this can be disabled if the name 47 * isn't important. 48 */ 49 val shouldPreserveName: Boolean = true 50 ) 51