Enable Kotlin explicit API mode for androidx keep annotations
Bug: b/392865072
Change-Id: If618e6d8966230066bd236c2757b830e5b98f78e
diff --git a/d8_r8/keepanno/build.gradle.kts b/d8_r8/keepanno/build.gradle.kts
index 02d2e85..717bd35 100644
--- a/d8_r8/keepanno/build.gradle.kts
+++ b/d8_r8/keepanno/build.gradle.kts
@@ -48,6 +48,10 @@
withSourcesJar()
}
+kotlin {
+ explicitApi()
+}
+
dependencies {
compileOnly(Deps.asm)
compileOnly(Deps.guava)
diff --git a/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt b/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt
index f8f1e97..a6c1ced 100644
--- a/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt
+++ b/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt
@@ -38,7 +38,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class AnnotationPattern(
+public annotation class AnnotationPattern(
/**
* Define the annotation-name pattern by fully qualified class name.
diff --git a/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt b/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt
index c85f0ea..75f69d6 100644
--- a/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt
+++ b/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt
@@ -43,4 +43,4 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class CheckOptimizedOut(val description: String = "")
+public annotation class CheckOptimizedOut(val description: String = "")
diff --git a/src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt b/src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt
index 0be0daa..66117a2 100644
--- a/src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt
+++ b/src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt
@@ -39,4 +39,4 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class CheckRemoved(val description: String = "")
+public annotation class CheckRemoved(val description: String = "")
diff --git a/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt
index 80cdeed..fb5a082 100644
--- a/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt
@@ -26,7 +26,7 @@
* <p>The negated elements make it easier to express the inverse as we cannot use a "not/negation"
* operation syntactically.
*/
-enum class ClassAccessFlags {
+public enum class ClassAccessFlags {
PUBLIC,
NON_PUBLIC,
PACKAGE_PRIVATE,
diff --git a/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt b/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt
index e01a876..44738b1 100644
--- a/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt
+++ b/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt
@@ -36,7 +36,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class ClassNamePattern(
+public annotation class ClassNamePattern(
/**
* Define the class-name pattern by fully qualified class name.
diff --git a/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt
index 11867e6..37c763c 100644
--- a/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt
@@ -26,7 +26,7 @@
* <p>The negated elements make it easier to express the inverse as we cannot use a "not/negation"
* operation syntactically.
*/
-enum class FieldAccessFlags {
+public enum class FieldAccessFlags {
// General member flags.
PUBLIC,
NON_PUBLIC,
diff --git a/src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.kt b/src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.kt
index 9387973..2331b13 100644
--- a/src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.kt
+++ b/src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.kt
@@ -35,7 +35,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class InstanceOfPattern(
+public annotation class InstanceOfPattern(
/**
* True if the pattern should include the directly matched classes.
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt b/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt
index b54b909..7d9730b 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt
@@ -45,7 +45,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class KeepBinding(
+public annotation class KeepBinding(
/**
* Name with which other bindings, conditions or targets can reference the bound item pattern.
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt b/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt
index a4fcddc..e149232 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt
@@ -41,7 +41,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class KeepCondition(
+public annotation class KeepCondition(
/**
* Define the class pattern by reference to a binding.
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt b/src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt
index 6eaebcc..f98d91b 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt
@@ -30,7 +30,7 @@
* it is safe to remove the annotations. However, it would not be safe to remove parameters from the
* method.
*/
-enum class KeepConstraint {
+public enum class KeepConstraint {
/**
* Indicates that the target item is being looked up reflectively.
*
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt b/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt
index 6e683e5..dc30799 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt
@@ -30,7 +30,7 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class KeepEdge(
+public annotation class KeepEdge(
val description: String = "",
// val retention : Array<RetentionPolicy> = [RetentionPolicy.RUNTIME]
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt b/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt
index 5fa5bf6..aecd426 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt
@@ -47,7 +47,7 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class KeepForApi(
+public annotation class KeepForApi(
/**
* Optional description to document the reason for this annotation.
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt b/src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt
index 90afbff..e30bd45 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt
@@ -20,7 +20,7 @@
package androidx.annotation.keep
-enum class KeepItemKind {
+public enum class KeepItemKind {
ONLY_CLASS,
ONLY_MEMBERS,
ONLY_METHODS,
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepOption.kt b/src/keepanno/java/androidx/annotation/keep/KeepOption.kt
index 13ef7f6..64035a7 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepOption.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepOption.kt
@@ -20,7 +20,7 @@
package androidx.annotation.keep
-enum class KeepOption {
+public enum class KeepOption {
SHRINKING,
OPTIMIZATION,
OBFUSCATION,
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt b/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt
index 7dbb4a2..6164c7e 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt
@@ -41,7 +41,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class KeepTarget(
+public annotation class KeepTarget(
/**
* Specify the kind of this item pattern.
diff --git a/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt
index 4985630..949a641 100644
--- a/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt
@@ -26,7 +26,7 @@
* <p>The negated elements make it easier to express the inverse as we cannot use a "not/negation"
* operation syntactically.
*/
-enum class MemberAccessFlags {
+public enum class MemberAccessFlags {
PUBLIC,
NON_PUBLIC,
PROTECTED,
diff --git a/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt
index a3fa2f7..3760256 100644
--- a/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt
@@ -26,7 +26,7 @@
* <p>The negated elements make it easier to express the inverse as we cannot use a "not/negation"
* operation syntactically.
*/
-enum class MethodAccessFlags {
+public enum class MethodAccessFlags {
// General member flags.
PUBLIC,
NON_PUBLIC,
diff --git a/src/keepanno/java/androidx/annotation/keep/StringPattern.kt b/src/keepanno/java/androidx/annotation/keep/StringPattern.kt
index bb872ec..15979fd 100644
--- a/src/keepanno/java/androidx/annotation/keep/StringPattern.kt
+++ b/src/keepanno/java/androidx/annotation/keep/StringPattern.kt
@@ -35,7 +35,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class StringPattern(
+public annotation class StringPattern(
/**
* Exact string content.
diff --git a/src/keepanno/java/androidx/annotation/keep/TypePattern.kt b/src/keepanno/java/androidx/annotation/keep/TypePattern.kt
index 0e87702..5e42220 100644
--- a/src/keepanno/java/androidx/annotation/keep/TypePattern.kt
+++ b/src/keepanno/java/androidx/annotation/keep/TypePattern.kt
@@ -39,7 +39,7 @@
*/
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class TypePattern(
+public annotation class TypePattern(
/**
* Exact type name as a string.
diff --git a/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt b/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt
index 677a344..5c5ab2c 100644
--- a/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt
+++ b/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt
@@ -53,7 +53,7 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class UsedByNative(
+public annotation class UsedByNative(
/**
* Optional description to document the reason for this annotation.
diff --git a/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt b/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt
index 7c9f85f..8f4c8db 100644
--- a/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt
+++ b/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt
@@ -53,7 +53,7 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class UsedByReflection(
+public annotation class UsedByReflection(
/**
* Optional description to document the reason for this annotation.
diff --git a/src/keepanno/java/androidx/annotation/keep/UsesReflection.kt b/src/keepanno/java/androidx/annotation/keep/UsesReflection.kt
index ced4530..021b186 100644
--- a/src/keepanno/java/androidx/annotation/keep/UsesReflection.kt
+++ b/src/keepanno/java/androidx/annotation/keep/UsesReflection.kt
@@ -82,7 +82,7 @@
AnnotationTarget.FUNCTION,
AnnotationTarget.CONSTRUCTOR,
)
-annotation class UsesReflection(
+public annotation class UsesReflection(
/**
* Optional description to document the reason for this annotation.
diff --git a/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java b/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java
index 1c27e1a..1cf4ed7 100644
--- a/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java
+++ b/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java
@@ -610,7 +610,7 @@
if (generateKotlin()) {
println("@Retention(AnnotationRetention.BINARY)");
println("@Target(AnnotationTarget.ANNOTATION_CLASS)");
- println("annotation class " + clazz + "(");
+ println("public annotation class " + clazz + "(");
} else {
println("@Target(ElementType.ANNOTATION_TYPE)");
println("@Retention(RetentionPolicy.CLASS)");
@@ -627,7 +627,7 @@
println(" AnnotationTarget.FUNCTION,");
println(" AnnotationTarget.CONSTRUCTOR,");
println(")");
- println("annotation class " + clazz + "(");
+ println("public annotation class " + clazz + "(");
} else {
println(
"@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,"