1*6777b538SAndroid Build Coastguard Worker# Copyright 2022 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker# found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker# Contains flags related to annotations in //build/android that can be safely 6*6777b538SAndroid Build Coastguard Worker# shared with Cronet, and thus would be appropriate for third-party apps to 7*6777b538SAndroid Build Coastguard Worker# include. 8*6777b538SAndroid Build Coastguard Worker 9*6777b538SAndroid Build Coastguard Worker# Keep all annotation related attributes that can affect runtime 10*6777b538SAndroid Build Coastguard Worker-keepattributes RuntimeVisible*Annotations 11*6777b538SAndroid Build Coastguard Worker-keepattributes AnnotationDefault 12*6777b538SAndroid Build Coastguard Worker 13*6777b538SAndroid Build Coastguard Worker# Keeps for class level annotations. 14*6777b538SAndroid Build Coastguard Worker-keep,allowaccessmodification @org.chromium.build.annotations.UsedByReflection class ** {} 15*6777b538SAndroid Build Coastguard Worker 16*6777b538SAndroid Build Coastguard Worker# Keeps for method level annotations. 17*6777b538SAndroid Build Coastguard Worker-keepclasseswithmembers,allowaccessmodification class ** { 18*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.UsedByReflection <methods>; 19*6777b538SAndroid Build Coastguard Worker} 20*6777b538SAndroid Build Coastguard Worker-keepclasseswithmembers,allowaccessmodification class ** { 21*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.UsedByReflection <fields>; 22*6777b538SAndroid Build Coastguard Worker} 23*6777b538SAndroid Build Coastguard Worker 24*6777b538SAndroid Build Coastguard Worker# Never inline classes, methods, or fields with this annotation, but allow 25*6777b538SAndroid Build Coastguard Worker# shrinking and obfuscation. 26*6777b538SAndroid Build Coastguard Worker# Relevant to fields when they are needed to store strong references to objects 27*6777b538SAndroid Build Coastguard Worker# that are held as weak references by native code. 28*6777b538SAndroid Build Coastguard Worker-if @org.chromium.build.annotations.DoNotInline class * { 29*6777b538SAndroid Build Coastguard Worker *** *(...); 30*6777b538SAndroid Build Coastguard Worker} 31*6777b538SAndroid Build Coastguard Worker-keep,allowobfuscation,allowaccessmodification class <1> { 32*6777b538SAndroid Build Coastguard Worker *** <2>(...); 33*6777b538SAndroid Build Coastguard Worker} 34*6777b538SAndroid Build Coastguard Worker-keepclassmembers,allowobfuscation,allowaccessmodification class * { 35*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.DoNotInline <methods>; 36*6777b538SAndroid Build Coastguard Worker} 37*6777b538SAndroid Build Coastguard Worker-keepclassmembers,allowobfuscation,allowaccessmodification class * { 38*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.DoNotInline <fields>; 39*6777b538SAndroid Build Coastguard Worker} 40*6777b538SAndroid Build Coastguard Worker 41*6777b538SAndroid Build Coastguard Worker-alwaysinline class * { 42*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.AlwaysInline *; 43*6777b538SAndroid Build Coastguard Worker} 44*6777b538SAndroid Build Coastguard Worker 45*6777b538SAndroid Build Coastguard Worker# Keep all logs (Log.VERBOSE = 2). R8 does not allow setting to 0. 46*6777b538SAndroid Build Coastguard Worker-maximumremovedandroidloglevel 1 class ** { 47*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.DoNotStripLogs <methods>; 48*6777b538SAndroid Build Coastguard Worker} 49*6777b538SAndroid Build Coastguard Worker-maximumremovedandroidloglevel 1 @org.chromium.build.annotations.DoNotStripLogs class ** { 50*6777b538SAndroid Build Coastguard Worker <methods>; 51*6777b538SAndroid Build Coastguard Worker} 52*6777b538SAndroid Build Coastguard Worker 53*6777b538SAndroid Build Coastguard Worker# Never merge classes horizontally or vertically with this annotation. 54*6777b538SAndroid Build Coastguard Worker# Relevant to classes being used as a key in maps or sets. 55*6777b538SAndroid Build Coastguard Worker-keep,allowaccessmodification,allowobfuscation,allowshrinking @org.chromium.build.annotations.DoNotClassMerge class * 56*6777b538SAndroid Build Coastguard Worker 57*6777b538SAndroid Build Coastguard Worker# Mark members annotated with IdentifierNameString as identifier name strings 58*6777b538SAndroid Build Coastguard Worker-identifiernamestring class * { 59*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.IdentifierNameString *; 60*6777b538SAndroid Build Coastguard Worker} 61*6777b538SAndroid Build Coastguard Worker 62*6777b538SAndroid Build Coastguard Worker# Mark fields with this to help R8 figure out that they cannot be null. 63*6777b538SAndroid Build Coastguard Worker-assumenosideeffects class ** { 64*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.AssumeNonNull *** *(...) return _NONNULL_; 65*6777b538SAndroid Build Coastguard Worker} 66*6777b538SAndroid Build Coastguard Worker-assumenosideeffects class ** { 67*6777b538SAndroid Build Coastguard Worker @org.chromium.build.annotations.AssumeNonNull *** * return _NONNULL_; 68*6777b538SAndroid Build Coastguard Worker} 69