diff options
author | 2025-01-09 11:05:11 +0100 | |
---|---|---|
committer | 2025-01-09 14:02:03 +0100 | |
commit | 8ec5f61a0293330dc75e1a68a4a887dcd0842a5a (patch) | |
tree | 63897ecc9870cd03a3518d8cad7092877b3206d0 | |
parent | 420177f2e105f119df46c008f969dd41dd28be47 (diff) |
Add property Optimize.Keep_runtime_invisible_annotations
This adds a new property Keep_runtime_invisible_annotations to Optimize that defaults to false.
Setting this property to true is equivalent to:
-keepattributes RuntimeInvisibleAnnotations,
RuntimeInvisibleParameterAnnotations,
RuntimeInvisibleTypeAnnotations
This is only applicable when RELEASE_R8_ONLY_RUNTIME_VISIBLE_ANNOTATIONS is enabled and will be used to migrate away from keeping runtime invisible annotations (b/387958004 ).
It is not possible to branch on RELEASE_R8_ONLY_RUNTIME_VISIBLE_ANNOTATIONS in ProGuard configuration files. To migrate builds away from keeping runtime invisible annotations, this will remove any -keepattributes rules that retain runtime invisible annotations, and set the property Optimize.Keep_runtime_invisible_annotations. This way these builds continue to retain runtime invisible annotations when the feature flag RELEASE_R8_ONLY_RUNTIME_VISIBLE_ANNOTATIONS is not enabled.
Bug: 387958004
Test: existing
Change-Id: I2a2b9aba436c4f43533d3067f2abe319fadf78f1
-rw-r--r-- | android/config.go | 4 | ||||
-rw-r--r-- | java/dex.go | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/android/config.go b/android/config.go index e9cb2cd31..da7382d9f 100644 --- a/android/config.go +++ b/android/config.go @@ -2168,6 +2168,10 @@ func (c *config) UseTransitiveJarsInClasspath() bool { return c.productVariables.GetBuildFlagBool("RELEASE_USE_TRANSITIVE_JARS_IN_CLASSPATH") } +func (c *config) UseR8OnlyRuntimeVisibleAnnotations() bool { + return c.productVariables.GetBuildFlagBool("RELEASE_R8_ONLY_RUNTIME_VISIBLE_ANNOTATIONS") +} + func (c *config) UseR8StoreStoreFenceConstructorInlining() bool { return c.productVariables.GetBuildFlagBool("RELEASE_R8_STORE_STORE_FENCE_CONSTRUCTOR_INLINING") } diff --git a/java/dex.go b/java/dex.go index 7b99549d4..4a7e9dcc4 100644 --- a/java/dex.go +++ b/java/dex.go @@ -49,6 +49,16 @@ type DexProperties struct { // Whether to continue building even if warnings are emitted. Defaults to true. Ignore_warnings *bool + // Whether runtime invisible annotations should be kept by R8. Defaults to false. + // This is equivalent to: + // -keepattributes RuntimeInvisibleAnnotations, + // RuntimeInvisibleParameterAnnotations, + // RuntimeInvisibleTypeAnnotations + // This is only applicable when RELEASE_R8_ONLY_RUNTIME_VISIBLE_ANNOTATIONS is + // enabled and will be used to migrate away from keeping runtime invisible + // annotations (b/387958004). + Keep_runtime_invisible_annotations *bool + // If true, runs R8 in Proguard compatibility mode, otherwise runs R8 in full mode. // Defaults to false for apps and tests, true for libraries. Proguard_compatibility *bool @@ -364,6 +374,10 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams, r8Flags = append(r8Flags, "--ignore-library-extends-program") } + if BoolDefault(opt.Keep_runtime_invisible_annotations, false) { + r8Flags = append(r8Flags, "--keep-runtime-invisible-annotations") + } + if BoolDefault(opt.Proguard_compatibility, true) { r8Flags = append(r8Flags, "--force-proguard-compatibility") } |