From 5be3cbad273a3512385ec3bde4d95a07100ff460 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 4 Aug 2017 16:39:05 -0700 Subject: Use class retention for VisibleForTesting annotations The VisibleForTesting annotations are used by proguard to prevent stripping code that is needed at runtime for tests. The annotations were marked with source retention, which worked fine with Jack's proguard implementation. When we switched back to javac + proguard, the VisibleForTesting annotations are gone by the time proguard sees the classes, so the annotated classes and methods can still be stripped. Move the VisibleForTesting annotation to class retention, which matches guava's equivalent annotation. Bug: 64365384 Test: m -j MtpDocumentsProvider && javap -cp out/target/common/obj/APPS/MtpDocumentsProvider_intermediates/classes-proguard.jar com.android.mtp.MtpRoot Change-Id: I63a467c2f0a21383eb9e4c9563fd6de2d994a373 Merged-In: I63a467c2f0a21383eb9e4c9563fd6de2d994a373 (cherry picked from commit 8e846143ddc285117d391561de7abd670078d27f) --- core/java/com/android/internal/annotations/VisibleForTesting.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/com/android/internal/annotations/VisibleForTesting.java b/core/java/com/android/internal/annotations/VisibleForTesting.java index bc3121c74e5f..99512ac68d5d 100644 --- a/core/java/com/android/internal/annotations/VisibleForTesting.java +++ b/core/java/com/android/internal/annotations/VisibleForTesting.java @@ -27,7 +27,7 @@ import java.lang.annotation.RetentionPolicy; * visibility should have been if it had not been made public or package-private for testing. * The default is to consider the element private. */ -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.CLASS) public @interface VisibleForTesting { /** * Intended visibility if the element had not been made public or package-private for -- cgit v1.2.3-59-g8ed1b