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