Ensure special Dalvik annotations are kept
These optimization annotations are special in that we don't want them
to have RUNTIME retention, but we do want them to be visible to ART.
R8 already has special rules to handle them, but with R8 full mode
it still requires a minimal keep rule for the given reference.
This allows usage of annotations like @NeverCompile from fully optimized
platform targets like SystemUI.
Bug: 215417388
Test: m + compare SystemUIGoogle.odex w/ @NeverCompile annotations
Change-Id: Id14bcc7b6d0d6dd385c60cfbe4d31f295cbaa5dc
diff --git a/core/proguard.flags b/core/proguard.flags
index d790061..6dbee84 100644
--- a/core/proguard.flags
+++ b/core/proguard.flags
@@ -51,4 +51,13 @@
@**android**.annotation*.Keep <init>(...);
}
+# Keep Dalvik optimization annotations. These annotations are special in that
+# 1) we want them preserved for visibility with ART, but 2) they don't have
+# RUNTIME retention. These minimal keep rules ensure they're not stripped by R8.
+# TODO(b/215417388): Export this rule from the owning library, core-libart,
+# via export_proguard_flags_files.
+-keepclassmembers,allowshrinking,allowoptimization,allowobfuscation,allowaccessmodification class * {
+ @dalvik.annotation.optimization.** *;
+}
+
-include proguard_basic_keeps.flags