Revert "Change the keep annotations in the androidx namespace to Kotlin source"
This reverts commit 495b038bd4fbe577e1000f2ce057c25baf94fd7f.
Reason for revert: Breaks SanityCheck
Change-Id: I623c8151bef34c0e97e75919b844b1ccb806a178
diff --git a/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.java b/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.java
new file mode 100644
index 0000000..aac8b68
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A pattern structure for matching annotations.
+ *
+ * <p>If no properties are set, the default pattern matches any annotation with a runtime retention
+ * policy.
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface AnnotationPattern {
+
+ /**
+ * Define the annotation-name pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining annotation-name:
+ *
+ * <ul>
+ * <li>constant
+ * <li>namePattern
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any annotation name.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String name() default "";
+
+ /**
+ * Define the annotation-name pattern by reference to a {@code Class} constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining annotation-name:
+ *
+ * <ul>
+ * <li>name
+ * <li>namePattern
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any annotation name.
+ *
+ * @return The Class constant that defines the annotation.
+ */
+ Class<?> constant() default Object.class;
+
+ /**
+ * Define the annotation-name pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining annotation-name:
+ *
+ * <ul>
+ * <li>name
+ * <li>constant
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any annotation name.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern namePattern() default @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Specify which retention policies must be set for the annotations.
+ *
+ * <p>Matches annotations with matching retention policies
+ *
+ * @return Retention policies. By default {@code RetentionPolicy.RUNTIME}.
+ */
+ RetentionPolicy[] retention() default {RetentionPolicy.RUNTIME};
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt b/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt
deleted file mode 100644
index f8f1e97..0000000
--- a/src/keepanno/java/androidx/annotation/keep/AnnotationPattern.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import java.lang.annotation.RetentionPolicy
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * A pattern structure for matching annotations.
- *
- * <p>
- * If no properties are set, the default pattern matches any annotation with a runtime retention
- * policy.
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class AnnotationPattern(
-
- /**
- * Define the annotation-name pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining annotation-name:
- * <ul>
- * <li>constant
- * <li>namePattern
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any annotation name.
- *
- * @return The qualified class name that defines the annotation.
- */
- val name: String = "",
-
- /**
- * Define the annotation-name pattern by reference to a {@code Class} constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining annotation-name:
- * <ul>
- * <li>name
- * <li>namePattern
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any annotation name.
- *
- * @return The Class constant that defines the annotation.
- */
- val constant: KClass<*> = Object::class,
-
- /**
- * Define the annotation-name pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining annotation-name:
- * <ul>
- * <li>name
- * <li>constant
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any annotation name.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val namePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Specify which retention policies must be set for the annotations.
- *
- * <p>
- * Matches annotations with matching retention policies
- *
- * @return Retention policies. By default {@code RetentionPolicy.RUNTIME}.
- */
- val retention: Array<RetentionPolicy> = [RetentionPolicy.RUNTIME],
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt b/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.java
similarity index 80%
rename from src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt
rename to src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.java
index c85f0ea..122ed7e 100644
--- a/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.kt
+++ b/src/keepanno/java/androidx/annotation/keep/CheckOptimizedOut.java
@@ -18,10 +18,12 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* Mark that an item must be optimized out of the residual program.
@@ -36,11 +38,9 @@
* inlining vs merging, the use of this annotation is somewhat unreliable and should be used with
* caution. In most cases it is more appropriate to use {@link CheckRemoved}.
*/
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.TYPE,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class CheckOptimizedOut(val description: String = "")
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface CheckOptimizedOut {
+
+ String description() default "";
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt b/src/keepanno/java/androidx/annotation/keep/CheckRemoved.java
similarity index 76%
rename from src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt
rename to src/keepanno/java/androidx/annotation/keep/CheckRemoved.java
index 0be0daa..20d2d5d 100644
--- a/src/keepanno/java/androidx/annotation/keep/CheckRemoved.kt
+++ b/src/keepanno/java/androidx/annotation/keep/CheckRemoved.java
@@ -18,10 +18,12 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* Mark that an item must be fully removed from the residual program.
@@ -32,11 +34,9 @@
*
* <p>A class is removed if all of its members are removed and no references to the class remain.
*/
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.TYPE,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class CheckRemoved(val description: String = "")
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface CheckRemoved {
+
+ String description() default "";
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.java
similarity index 93%
rename from src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt
rename to src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.java
index 80cdeed..0d4e765 100644
--- a/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/ClassAccessFlags.java
@@ -18,7 +18,7 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
/**
* Valid matches on class access flags and their negations.
@@ -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 ClassAccessFlags {
PUBLIC,
NON_PUBLIC,
PACKAGE_PRIVATE,
@@ -42,5 +42,5 @@
ANNOTATION,
NON_ANNOTATION,
ENUM,
- NON_ENUM,
+ NON_ENUM
}
diff --git a/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.java b/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.java
new file mode 100644
index 0000000..299bf04
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A pattern structure for matching names of classes and interfaces.
+ *
+ * <p>If no properties are set, the default pattern matches any name of a class or interface.
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface ClassNamePattern {
+
+ /**
+ * Define the class-name pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>constant
+ * <li>unqualifiedName
+ * <li>unqualifiedNamePattern
+ * <li>packageName
+ * </ul>
+ *
+ * @return The qualified class name that defines the class.
+ */
+ String name() default "";
+
+ /**
+ * Define the class-name pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>name
+ * <li>unqualifiedName
+ * <li>unqualifiedNamePattern
+ * <li>packageName
+ * </ul>
+ *
+ * @return The class-constant that defines the class.
+ */
+ Class<?> constant() default Object.class;
+
+ /**
+ * Exact and unqualified name of the class or interface.
+ *
+ * <p>For example, the unqualified name of {@code com.example.MyClass} is {@code MyClass}. Note
+ * that for inner classes a `$` will appear in the unqualified name,such as, {@code
+ * MyClass$MyInnerClass}.
+ *
+ * <p>The default matches any unqualified name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-unqualified-name:
+ *
+ * <ul>
+ * <li>unqualifiedNamePattern
+ * <li>name
+ * <li>constant
+ * </ul>
+ */
+ String unqualifiedName() default "";
+
+ /**
+ * Define the unqualified class-name pattern by a string pattern.
+ *
+ * <p>The default matches any unqualified name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-unqualified-name:
+ *
+ * <ul>
+ * <li>unqualifiedName
+ * <li>name
+ * <li>constant
+ * </ul>
+ *
+ * @return The string pattern of the unqualified class name.
+ */
+ StringPattern unqualifiedNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Exact package name of the class or interface.
+ *
+ * <p>For example, the package of {@code com.example.MyClass} is {@code com.example}.
+ *
+ * <p>The default matches any package.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-package-name:
+ *
+ * <ul>
+ * <li>name
+ * <li>constant
+ * </ul>
+ */
+ String packageName() default "";
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt b/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt
deleted file mode 100644
index e01a876..0000000
--- a/src/keepanno/java/androidx/annotation/keep/ClassNamePattern.kt
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * A pattern structure for matching names of classes and interfaces.
- *
- * <p>
- * If no properties are set, the default pattern matches any name of a class or interface.
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class ClassNamePattern(
-
- /**
- * Define the class-name pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>constant
- * <li>unqualifiedName
- * <li>unqualifiedNamePattern
- * <li>packageName
- * </ul>
- *
- * @return The qualified class name that defines the class.
- */
- val name: String = "",
-
- /**
- * Define the class-name pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>name
- * <li>unqualifiedName
- * <li>unqualifiedNamePattern
- * <li>packageName
- * </ul>
- *
- * @return The class-constant that defines the class.
- */
- val constant: KClass<*> = Object::class,
-
- /**
- * Exact and unqualified name of the class or interface.
- *
- * <p>
- * For example, the unqualified name of {@code com.example.MyClass} is {@code MyClass}. Note that
- * for inner classes a `$` will appear in the unqualified name,such as, {@code
- * MyClass$MyInnerClass}.
- *
- * <p>
- * The default matches any unqualified name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-unqualified-name:
- * <ul>
- * <li>unqualifiedNamePattern
- * <li>name
- * <li>constant
- * </ul>
- */
- val unqualifiedName: String = "",
-
- /**
- * Define the unqualified class-name pattern by a string pattern.
- *
- * <p>
- * The default matches any unqualified name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-unqualified-name:
- * <ul>
- * <li>unqualifiedName
- * <li>name
- * <li>constant
- * </ul>
- *
- * @return The string pattern of the unqualified class name.
- */
- val unqualifiedNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Exact package name of the class or interface.
- *
- * <p>
- * For example, the package of {@code com.example.MyClass} is {@code com.example}.
- *
- * <p>
- * The default matches any package.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-package-name:
- * <ul>
- * <li>name
- * <li>constant
- * </ul>
- */
- val packageName: String = "",
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.java
similarity index 95%
rename from src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt
rename to src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.java
index 11867e6..9b28dec 100644
--- a/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/FieldAccessFlags.java
@@ -18,7 +18,7 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
/**
* Valid matches on field access flags and their negations.
@@ -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 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.java
similarity index 68%
rename from src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.kt
rename to src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.java
index 9387973..9e55d6a 100644
--- a/src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.kt
+++ b/src/keepanno/java/androidx/annotation/keep/InstanceOfPattern.java
@@ -22,30 +22,30 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* A pattern structure for matching instances of classes and interfaces.
*
- * <p>
- * If no properties are set, the default pattern matches any instance.
+ * <p>If no properties are set, the default pattern matches any instance.
*/
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class InstanceOfPattern(
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface InstanceOfPattern {
/**
* True if the pattern should include the directly matched classes.
*
- * <p>
- * If false, the pattern is exclusive and only matches classes that are strict subclasses of the
- * pattern.
+ * <p>If false, the pattern is exclusive and only matches classes that are strict subclasses of
+ * the pattern.
*/
- val inclusive: Boolean = true,
+ boolean inclusive() default true;
/** Instances of classes matching the class-name pattern. */
- val classNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-)
+ ClassNamePattern classNamePattern() default @ClassNamePattern(unqualifiedName = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepBinding.java b/src/keepanno/java/androidx/annotation/keep/KeepBinding.java
new file mode 100644
index 0000000..a15e97e
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/KeepBinding.java
@@ -0,0 +1,722 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A binding of a keep item.
+ *
+ * <p>Bindings allow referencing the exact instance of a match from a condition in other conditions
+ * and/or targets. It can also be used to reduce duplication of targets by sharing patterns.
+ *
+ * <p>An item can be:
+ *
+ * <ul>
+ * <li>a pattern on classes;
+ * <li>a pattern on methods; or
+ * <li>a pattern on fields.
+ * </ul>
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface KeepBinding {
+
+ /**
+ * Name with which other bindings, conditions or targets can reference the bound item pattern.
+ *
+ * @return Name of the binding.
+ */
+ String bindingName();
+
+ /**
+ * Specify the kind of this item pattern.
+ *
+ * <p>Possible values are:
+ *
+ * <ul>
+ * <li>{@link KeepItemKind#ONLY_CLASS}
+ * <li>{@link KeepItemKind#ONLY_MEMBERS}
+ * <li>{@link KeepItemKind#ONLY_METHODS}
+ * <li>{@link KeepItemKind#ONLY_FIELDS}
+ * <li>{@link KeepItemKind#CLASS_AND_MEMBERS}
+ * <li>{@link KeepItemKind#CLASS_AND_METHODS}
+ * <li>{@link KeepItemKind#CLASS_AND_FIELDS}
+ * </ul>
+ *
+ * <p>If unspecified the default kind for an item depends on its member patterns:
+ *
+ * <ul>
+ * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined
+ * <li>{@link KeepItemKind#ONLY_METHODS} if method patterns are defined
+ * <li>{@link KeepItemKind#ONLY_FIELDS} if field patterns are defined
+ * <li>{@link KeepItemKind#ONLY_MEMBERS} otherwise.
+ * </ul>
+ *
+ * @return The kind for this pattern.
+ */
+ KeepItemKind kind() default KeepItemKind.DEFAULT;
+
+ /**
+ * Define the class pattern by reference to a binding.
+ *
+ * <p>Mutually exclusive with the following other properties defining class:
+ *
+ * <ul>
+ * <li>className
+ * <li>classConstant
+ * <li>classNamePattern
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassConstant
+ * <li>classAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class.
+ *
+ * @return The name of the binding that defines the class.
+ */
+ String classFromBinding() default "";
+
+ /**
+ * Define the class-name pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>classConstant
+ * <li>classNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The qualified class name that defines the class.
+ */
+ String className() default "";
+
+ /**
+ * Define the class-name pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>className
+ * <li>classNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The class-constant that defines the class.
+ */
+ Class<?> classConstant() default Object.class;
+
+ /**
+ * Define the class-name pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>className
+ * <li>classConstant
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The class-name pattern that defines the class.
+ */
+ ClassNamePattern classNamePattern() default @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the instance-of pattern as classes that are instances of the fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The qualified class name that defines what instance-of the class must be.
+ */
+ String instanceOfClassName() default "";
+
+ /**
+ * Define the instance-of pattern as classes that are instances of the fully qualified class name.
+ *
+ * <p>The pattern is exclusive in that it does not match classes that are instances of the
+ * pattern, but only those that are instances of classes that are subclasses of the pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The qualified class name that defines what instance-of the class must be.
+ */
+ String instanceOfClassNameExclusive() default "";
+
+ /**
+ * Define the instance-of pattern as classes that are instances the referenced Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The class constant that defines what instance-of the class must be.
+ */
+ Class<?> instanceOfClassConstant() default Object.class;
+
+ /**
+ * Define the instance-of pattern as classes that are instances the referenced Class constant.
+ *
+ * <p>The pattern is exclusive in that it does not match classes that are instances of the
+ * pattern, but only those that are instances of classes that are subclasses of the pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The class constant that defines what instance-of the class must be.
+ */
+ Class<?> instanceOfClassConstantExclusive() default Object.class;
+
+ /**
+ * Define the instance-of with a pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The pattern that defines what instance-of the class must be.
+ */
+ InstanceOfPattern instanceOfPattern() default @InstanceOfPattern();
+
+ /**
+ * Define the class-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassConstant
+ * <li>classAnnotatedByClassNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String classAnnotatedByClassName() default "";
+
+ /**
+ * Define the class-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> classAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the class-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassConstant
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern classAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String memberAnnotatedByClassName() default "";
+
+ /**
+ * Define the member-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> memberAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the member-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern memberAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * @return The member access-flag constraints that must be met.
+ */
+ MemberAccessFlags[] memberAccess() default {};
+
+ /**
+ * Define the method-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassConstant
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String methodAnnotatedByClassName() default "";
+
+ /**
+ * Define the method-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> methodAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the method-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern methodAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the method-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * method-access flags.
+ *
+ * @return The method access-flag constraints that must be met.
+ */
+ MethodAccessFlags[] methodAccess() default {};
+
+ /**
+ * Define the method-name pattern by an exact method name.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodNamePattern` also defining method-name.
+ *
+ * @return The exact method name of the method.
+ */
+ String methodName() default "";
+
+ /**
+ * Define the method-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodName` also defining method-name.
+ *
+ * @return The string pattern of the method name.
+ */
+ StringPattern methodNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the method return-type pattern by a fully qualified type or 'void'.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnTypeConstant
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return The qualified type name of the method return type.
+ */
+ String methodReturnType() default "";
+
+ /**
+ * Define the method return-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return A class constant denoting the type of the method return type.
+ */
+ Class<?> methodReturnTypeConstant() default Object.class;
+
+ /**
+ * Define the method return-type pattern by a type pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypeConstant
+ * </ul>
+ *
+ * @return The pattern of the method return type.
+ */
+ TypePattern methodReturnTypePattern() default @TypePattern(name = "");
+
+ /**
+ * Define the method parameters pattern by a list of fully qualified types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
+ *
+ * @return The list of qualified type names of the method parameters.
+ */
+ String[] methodParameters() default {""};
+
+ /**
+ * Define the method parameters pattern by a list of patterns on types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameters` also defining parameters.
+ *
+ * @return The list of type patterns for the method parameters.
+ */
+ TypePattern[] methodParameterTypePatterns() default {@TypePattern(name = "")};
+
+ /**
+ * Define the field-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassConstant
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String fieldAnnotatedByClassName() default "";
+
+ /**
+ * Define the field-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> fieldAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the field-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern fieldAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the field-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any
+ * field-access flags.
+ *
+ * @return The field access-flag constraints that must be met.
+ */
+ FieldAccessFlags[] fieldAccess() default {};
+
+ /**
+ * Define the field-name pattern by an exact field name.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldNamePattern` also defining field-name.
+ *
+ * @return The exact field name of the field.
+ */
+ String fieldName() default "";
+
+ /**
+ * Define the field-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldName` also defining field-name.
+ *
+ * @return The string pattern of the field name.
+ */
+ StringPattern fieldNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the field-type pattern by a fully qualified type.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldTypeConstant
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The qualified type name for the field type.
+ */
+ String fieldType() default "";
+
+ /**
+ * Define the field-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The class constant for the field type.
+ */
+ Class<?> fieldTypeConstant() default Object.class;
+
+ /**
+ * Define the field-type pattern by a pattern on types.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypeConstant
+ * </ul>
+ *
+ * @return The type pattern for the field type.
+ */
+ TypePattern fieldTypePattern() default @TypePattern(name = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt b/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt
deleted file mode 100644
index b54b909..0000000
--- a/src/keepanno/java/androidx/annotation/keep/KeepBinding.kt
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * A binding of a keep item.
- *
- * <p>
- * Bindings allow referencing the exact instance of a match from a condition in other conditions
- * and/or targets. It can also be used to reduce duplication of targets by sharing patterns.
- *
- * <p>
- * An item can be:
- * <ul>
- * <li>a pattern on classes;
- * <li>a pattern on methods; or
- * <li>a pattern on fields.
- * </ul>
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class KeepBinding(
-
- /**
- * Name with which other bindings, conditions or targets can reference the bound item pattern.
- *
- * @return Name of the binding.
- */
- val bindingName: String,
-
- /**
- * Specify the kind of this item pattern.
- *
- * <p>
- * Possible values are:
- * <ul>
- * <li>{@link KeepItemKind#ONLY_CLASS}
- * <li>{@link KeepItemKind#ONLY_MEMBERS}
- * <li>{@link KeepItemKind#ONLY_METHODS}
- * <li>{@link KeepItemKind#ONLY_FIELDS}
- * <li>{@link KeepItemKind#CLASS_AND_MEMBERS}
- * <li>{@link KeepItemKind#CLASS_AND_METHODS}
- * <li>{@link KeepItemKind#CLASS_AND_FIELDS}
- * </ul>
- *
- * <p>
- * If unspecified the default kind for an item depends on its member patterns:
- * <ul>
- * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined
- * <li>{@link KeepItemKind#ONLY_METHODS} if method patterns are defined
- * <li>{@link KeepItemKind#ONLY_FIELDS} if field patterns are defined
- * <li>{@link KeepItemKind#ONLY_MEMBERS} otherwise.
- * </ul>
- *
- * @return The kind for this pattern.
- */
- val kind: KeepItemKind = KeepItemKind.DEFAULT,
-
- /**
- * Define the class pattern by reference to a binding.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class:
- * <ul>
- * <li>className
- * <li>classConstant
- * <li>classNamePattern
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassConstant
- * <li>classAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class.
- *
- * @return The name of the binding that defines the class.
- */
- val classFromBinding: String = "",
-
- /**
- * Define the class-name pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>classConstant
- * <li>classNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The qualified class name that defines the class.
- */
- val className: String = "",
-
- /**
- * Define the class-name pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>className
- * <li>classNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The class-constant that defines the class.
- */
- val classConstant: KClass<*> = Object::class,
-
- /**
- * Define the class-name pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>className
- * <li>classConstant
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The class-name pattern that defines the class.
- */
- val classNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the instance-of pattern as classes that are instances of the fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The qualified class name that defines what instance-of the class must be.
- */
- val instanceOfClassName: String = "",
-
- /**
- * Define the instance-of pattern as classes that are instances of the fully qualified class name.
- *
- * <p>
- * The pattern is exclusive in that it does not match classes that are instances of the pattern,
- * but only those that are instances of classes that are subclasses of the pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The qualified class name that defines what instance-of the class must be.
- */
- val instanceOfClassNameExclusive: String = "",
-
- /**
- * Define the instance-of pattern as classes that are instances the referenced Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The class constant that defines what instance-of the class must be.
- */
- val instanceOfClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the instance-of pattern as classes that are instances the referenced Class constant.
- *
- * <p>
- * The pattern is exclusive in that it does not match classes that are instances of the pattern,
- * but only those that are instances of classes that are subclasses of the pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The class constant that defines what instance-of the class must be.
- */
- val instanceOfClassConstantExclusive: KClass<*> = Object::class,
-
- /**
- * Define the instance-of with a pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The pattern that defines what instance-of the class must be.
- */
- val instanceOfPattern: InstanceOfPattern = InstanceOfPattern(),
-
- /**
- * Define the class-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassConstant
- * <li>classAnnotatedByClassNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val classAnnotatedByClassName: String = "",
-
- /**
- * Define the class-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val classAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the class-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassConstant
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val classAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassConstant
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val memberAnnotatedByClassName: String = "",
-
- /**
- * Define the member-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val memberAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the member-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val memberAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * @return The member access-flag constraints that must be met.
- */
- val memberAccess: Array<MemberAccessFlags> = [],
-
- /**
- * Define the method-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassConstant
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val methodAnnotatedByClassName: String = "",
-
- /**
- * Define the method-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val methodAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the method-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val methodAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the method-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any
- * method-access flags.
- *
- * @return The method access-flag constraints that must be met.
- */
- val methodAccess: Array<MethodAccessFlags> = [],
-
- /**
- * Define the method-name pattern by an exact method name.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodNamePattern` also defining method-name.
- *
- * @return The exact method name of the method.
- */
- val methodName: String = "",
-
- /**
- * Define the method-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodName` also defining method-name.
- *
- * @return The string pattern of the method name.
- */
- val methodNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the method return-type pattern by a fully qualified type or 'void'.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnTypeConstant
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return The qualified type name of the method return type.
- */
- val methodReturnType: String = "",
-
- /**
- * Define the method return-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return A class constant denoting the type of the method return type.
- */
- val methodReturnTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the method return-type pattern by a type pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypeConstant
- * </ul>
- *
- * @return The pattern of the method return type.
- */
- val methodReturnTypePattern: TypePattern = TypePattern(name = ""),
-
- /**
- * Define the method parameters pattern by a list of fully qualified types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
- *
- * @return The list of qualified type names of the method parameters.
- */
- val methodParameters: Array<String> = [""],
-
- /**
- * Define the method parameters pattern by a list of patterns on types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameters` also defining parameters.
- *
- * @return The list of type patterns for the method parameters.
- */
- val methodParameterTypePatterns: Array<TypePattern> = [TypePattern(name = "")],
-
- /**
- * Define the field-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassConstant
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val fieldAnnotatedByClassName: String = "",
-
- /**
- * Define the field-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val fieldAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val fieldAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the field-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field-access
- * flags.
- *
- * @return The field access-flag constraints that must be met.
- */
- val fieldAccess: Array<FieldAccessFlags> = [],
-
- /**
- * Define the field-name pattern by an exact field name.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldNamePattern` also defining field-name.
- *
- * @return The exact field name of the field.
- */
- val fieldName: String = "",
-
- /**
- * Define the field-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldName` also defining field-name.
- *
- * @return The string pattern of the field name.
- */
- val fieldNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the field-type pattern by a fully qualified type.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldTypeConstant
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The qualified type name for the field type.
- */
- val fieldType: String = "",
-
- /**
- * Define the field-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The class constant for the field type.
- */
- val fieldTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-type pattern by a pattern on types.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypeConstant
- * </ul>
- *
- * @return The type pattern for the field type.
- */
- val fieldTypePattern: TypePattern = TypePattern(name = ""),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepCondition.java b/src/keepanno/java/androidx/annotation/keep/KeepCondition.java
new file mode 100644
index 0000000..1a0cd79
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/KeepCondition.java
@@ -0,0 +1,745 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A condition for a keep edge.
+ *
+ * <p>The condition denotes an item used as a precondition of a rule. An item can be:
+ *
+ * <ul>
+ * <li>a pattern on classes;
+ * <li>a pattern on methods; or
+ * <li>a pattern on fields.
+ * </ul>
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface KeepCondition {
+
+ /**
+ * Define the class pattern by reference to a binding.
+ *
+ * <p>Mutually exclusive with the following other properties defining class:
+ *
+ * <ul>
+ * <li>className
+ * <li>classConstant
+ * <li>classNamePattern
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassConstant
+ * <li>classAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class.
+ *
+ * @return The name of the binding that defines the class.
+ */
+ String classFromBinding() default "";
+
+ /**
+ * Define the class-name pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>classConstant
+ * <li>classNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The qualified class name that defines the class.
+ */
+ String className() default "";
+
+ /**
+ * Define the class-name pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>className
+ * <li>classNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The class-constant that defines the class.
+ */
+ Class<?> classConstant() default Object.class;
+
+ /**
+ * Define the class-name pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>className
+ * <li>classConstant
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The class-name pattern that defines the class.
+ */
+ ClassNamePattern classNamePattern() default @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the instance-of pattern as classes that are instances of the fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The qualified class name that defines what instance-of the class must be.
+ */
+ String instanceOfClassName() default "";
+
+ /**
+ * Define the instance-of pattern as classes that are instances of the fully qualified class name.
+ *
+ * <p>The pattern is exclusive in that it does not match classes that are instances of the
+ * pattern, but only those that are instances of classes that are subclasses of the pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The qualified class name that defines what instance-of the class must be.
+ */
+ String instanceOfClassNameExclusive() default "";
+
+ /**
+ * Define the instance-of pattern as classes that are instances the referenced Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The class constant that defines what instance-of the class must be.
+ */
+ Class<?> instanceOfClassConstant() default Object.class;
+
+ /**
+ * Define the instance-of pattern as classes that are instances the referenced Class constant.
+ *
+ * <p>The pattern is exclusive in that it does not match classes that are instances of the
+ * pattern, but only those that are instances of classes that are subclasses of the pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The class constant that defines what instance-of the class must be.
+ */
+ Class<?> instanceOfClassConstantExclusive() default Object.class;
+
+ /**
+ * Define the instance-of with a pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The pattern that defines what instance-of the class must be.
+ */
+ InstanceOfPattern instanceOfPattern() default @InstanceOfPattern();
+
+ /**
+ * Define the class-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassConstant
+ * <li>classAnnotatedByClassNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String classAnnotatedByClassName() default "";
+
+ /**
+ * Define the class-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> classAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the class-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassConstant
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern classAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member pattern in full by a reference to a binding.
+ *
+ * <p>Mutually exclusive with all other class and member pattern properties. When a member binding
+ * is referenced this item is defined to be that item, including its class and member patterns.
+ *
+ * @return The binding name that defines the member.
+ */
+ String memberFromBinding() default "";
+
+ /**
+ * Define the member-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String memberAnnotatedByClassName() default "";
+
+ /**
+ * Define the member-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> memberAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the member-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern memberAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>Mutually exclusive with the property `memberFromBinding` also defining member-access.
+ *
+ * @return The member access-flag constraints that must be met.
+ */
+ MemberAccessFlags[] memberAccess() default {};
+
+ /**
+ * Define the method-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassConstant
+ * <li>methodAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String methodAnnotatedByClassName() default "";
+
+ /**
+ * Define the method-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> methodAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the method-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern methodAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the method-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * method-access flags.
+ *
+ * <p>Mutually exclusive with the property `memberFromBinding` also defining method-access.
+ *
+ * @return The method access-flag constraints that must be met.
+ */
+ MethodAccessFlags[] methodAccess() default {};
+
+ /**
+ * Define the method-name pattern by an exact method name.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-name:
+ *
+ * <ul>
+ * <li>methodNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The exact method name of the method.
+ */
+ String methodName() default "";
+
+ /**
+ * Define the method-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-name:
+ *
+ * <ul>
+ * <li>methodName
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The string pattern of the method name.
+ */
+ StringPattern methodNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the method return-type pattern by a fully qualified type or 'void'.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnTypeConstant
+ * <li>methodReturnTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The qualified type name of the method return type.
+ */
+ String methodReturnType() default "";
+
+ /**
+ * Define the method return-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return A class constant denoting the type of the method return type.
+ */
+ Class<?> methodReturnTypeConstant() default Object.class;
+
+ /**
+ * Define the method return-type pattern by a type pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypeConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The pattern of the method return type.
+ */
+ TypePattern methodReturnTypePattern() default @TypePattern(name = "");
+
+ /**
+ * Define the method parameters pattern by a list of fully qualified types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the following other properties defining parameters:
+ *
+ * <ul>
+ * <li>methodParameterTypePatterns
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The list of qualified type names of the method parameters.
+ */
+ String[] methodParameters() default {""};
+
+ /**
+ * Define the method parameters pattern by a list of patterns on types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the following other properties defining parameters:
+ *
+ * <ul>
+ * <li>methodParameters
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The list of type patterns for the method parameters.
+ */
+ TypePattern[] methodParameterTypePatterns() default {@TypePattern(name = "")};
+
+ /**
+ * Define the field-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassConstant
+ * <li>fieldAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String fieldAnnotatedByClassName() default "";
+
+ /**
+ * Define the field-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> fieldAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the field-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern fieldAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the field-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any
+ * field-access flags.
+ *
+ * <p>Mutually exclusive with the property `memberFromBinding` also defining field-access.
+ *
+ * @return The field access-flag constraints that must be met.
+ */
+ FieldAccessFlags[] fieldAccess() default {};
+
+ /**
+ * Define the field-name pattern by an exact field name.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-name:
+ *
+ * <ul>
+ * <li>fieldNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The exact field name of the field.
+ */
+ String fieldName() default "";
+
+ /**
+ * Define the field-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-name:
+ *
+ * <ul>
+ * <li>fieldName
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The string pattern of the field name.
+ */
+ StringPattern fieldNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the field-type pattern by a fully qualified type.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldTypeConstant
+ * <li>fieldTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The qualified type name for the field type.
+ */
+ String fieldType() default "";
+
+ /**
+ * Define the field-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The class constant for the field type.
+ */
+ Class<?> fieldTypeConstant() default Object.class;
+
+ /**
+ * Define the field-type pattern by a pattern on types.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypeConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The type pattern for the field type.
+ */
+ TypePattern fieldTypePattern() default @TypePattern(name = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt b/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt
deleted file mode 100644
index a4fcddc..0000000
--- a/src/keepanno/java/androidx/annotation/keep/KeepCondition.kt
+++ /dev/null
@@ -1,801 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * A condition for a keep edge.
- *
- * <p>
- * The condition denotes an item used as a precondition of a rule. An item can be:
- * <ul>
- * <li>a pattern on classes;
- * <li>a pattern on methods; or
- * <li>a pattern on fields.
- * </ul>
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class KeepCondition(
-
- /**
- * Define the class pattern by reference to a binding.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class:
- * <ul>
- * <li>className
- * <li>classConstant
- * <li>classNamePattern
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassConstant
- * <li>classAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class.
- *
- * @return The name of the binding that defines the class.
- */
- val classFromBinding: String = "",
-
- /**
- * Define the class-name pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>classConstant
- * <li>classNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The qualified class name that defines the class.
- */
- val className: String = "",
-
- /**
- * Define the class-name pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>className
- * <li>classNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The class-constant that defines the class.
- */
- val classConstant: KClass<*> = Object::class,
-
- /**
- * Define the class-name pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>className
- * <li>classConstant
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The class-name pattern that defines the class.
- */
- val classNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the instance-of pattern as classes that are instances of the fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The qualified class name that defines what instance-of the class must be.
- */
- val instanceOfClassName: String = "",
-
- /**
- * Define the instance-of pattern as classes that are instances of the fully qualified class name.
- *
- * <p>
- * The pattern is exclusive in that it does not match classes that are instances of the pattern,
- * but only those that are instances of classes that are subclasses of the pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The qualified class name that defines what instance-of the class must be.
- */
- val instanceOfClassNameExclusive: String = "",
-
- /**
- * Define the instance-of pattern as classes that are instances the referenced Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The class constant that defines what instance-of the class must be.
- */
- val instanceOfClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the instance-of pattern as classes that are instances the referenced Class constant.
- *
- * <p>
- * The pattern is exclusive in that it does not match classes that are instances of the pattern,
- * but only those that are instances of classes that are subclasses of the pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The class constant that defines what instance-of the class must be.
- */
- val instanceOfClassConstantExclusive: KClass<*> = Object::class,
-
- /**
- * Define the instance-of with a pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The pattern that defines what instance-of the class must be.
- */
- val instanceOfPattern: InstanceOfPattern = InstanceOfPattern(),
-
- /**
- * Define the class-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassConstant
- * <li>classAnnotatedByClassNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val classAnnotatedByClassName: String = "",
-
- /**
- * Define the class-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val classAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the class-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassConstant
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val classAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member pattern in full by a reference to a binding.
- *
- * <p>
- * Mutually exclusive with all other class and member pattern properties. When a member binding is
- * referenced this item is defined to be that item, including its class and member patterns.
- *
- * @return The binding name that defines the member.
- */
- val memberFromBinding: String = "",
-
- /**
- * Define the member-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassConstant
- * <li>memberAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val memberAnnotatedByClassName: String = "",
-
- /**
- * Define the member-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val memberAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the member-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassConstant
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val memberAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * Mutually exclusive with the property `memberFromBinding` also defining member-access.
- *
- * @return The member access-flag constraints that must be met.
- */
- val memberAccess: Array<MemberAccessFlags> = [],
-
- /**
- * Define the method-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassConstant
- * <li>methodAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val methodAnnotatedByClassName: String = "",
-
- /**
- * Define the method-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val methodAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the method-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassConstant
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val methodAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the method-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any
- * method-access flags.
- *
- * <p>
- * Mutually exclusive with the property `memberFromBinding` also defining method-access.
- *
- * @return The method access-flag constraints that must be met.
- */
- val methodAccess: Array<MethodAccessFlags> = [],
-
- /**
- * Define the method-name pattern by an exact method name.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-name:
- * <ul>
- * <li>methodNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The exact method name of the method.
- */
- val methodName: String = "",
-
- /**
- * Define the method-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-name:
- * <ul>
- * <li>methodName
- * <li>memberFromBinding
- * </ul>
- *
- * @return The string pattern of the method name.
- */
- val methodNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the method return-type pattern by a fully qualified type or 'void'.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnTypeConstant
- * <li>methodReturnTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The qualified type name of the method return type.
- */
- val methodReturnType: String = "",
-
- /**
- * Define the method return-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return A class constant denoting the type of the method return type.
- */
- val methodReturnTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the method return-type pattern by a type pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypeConstant
- * <li>memberFromBinding
- * </ul>
- *
- * @return The pattern of the method return type.
- */
- val methodReturnTypePattern: TypePattern = TypePattern(name = ""),
-
- /**
- * Define the method parameters pattern by a list of fully qualified types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the following other properties defining parameters:
- * <ul>
- * <li>methodParameterTypePatterns
- * <li>memberFromBinding
- * </ul>
- *
- * @return The list of qualified type names of the method parameters.
- */
- val methodParameters: Array<String> = [""],
-
- /**
- * Define the method parameters pattern by a list of patterns on types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the following other properties defining parameters:
- * <ul>
- * <li>methodParameters
- * <li>memberFromBinding
- * </ul>
- *
- * @return The list of type patterns for the method parameters.
- */
- val methodParameterTypePatterns: Array<TypePattern> = [TypePattern(name = "")],
-
- /**
- * Define the field-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassConstant
- * <li>fieldAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val fieldAnnotatedByClassName: String = "",
-
- /**
- * Define the field-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val fieldAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassConstant
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val fieldAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the field-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field-access
- * flags.
- *
- * <p>
- * Mutually exclusive with the property `memberFromBinding` also defining field-access.
- *
- * @return The field access-flag constraints that must be met.
- */
- val fieldAccess: Array<FieldAccessFlags> = [],
-
- /**
- * Define the field-name pattern by an exact field name.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-name:
- * <ul>
- * <li>fieldNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The exact field name of the field.
- */
- val fieldName: String = "",
-
- /**
- * Define the field-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-name:
- * <ul>
- * <li>fieldName
- * <li>memberFromBinding
- * </ul>
- *
- * @return The string pattern of the field name.
- */
- val fieldNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the field-type pattern by a fully qualified type.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldTypeConstant
- * <li>fieldTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The qualified type name for the field type.
- */
- val fieldType: String = "",
-
- /**
- * Define the field-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The class constant for the field type.
- */
- val fieldTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-type pattern by a pattern on types.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypeConstant
- * <li>memberFromBinding
- * </ul>
- *
- * @return The type pattern for the field type.
- */
- val fieldTypePattern: TypePattern = TypePattern(name = ""),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt b/src/keepanno/java/androidx/annotation/keep/KeepConstraint.java
similarity index 98%
rename from src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt
rename to src/keepanno/java/androidx/annotation/keep/KeepConstraint.java
index 6eaebcc..19f48dc 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepConstraint.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepConstraint.java
@@ -18,7 +18,8 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+
+package androidx.annotation.keep;
/**
* Usage constraints for how a target is used and what must be kept.
@@ -30,7 +31,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 KeepConstraint {
/**
* Indicates that the target item is being looked up reflectively.
*
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepOption.kt b/src/keepanno/java/androidx/annotation/keep/KeepEdge.java
similarity index 63%
copy from src/keepanno/java/androidx/annotation/keep/KeepOption.kt
copy to src/keepanno/java/androidx/annotation/keep/KeepEdge.java
index 13ef7f6..b4e3830 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepOption.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepEdge.java
@@ -18,12 +18,21 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-enum class KeepOption {
- SHRINKING,
- OPTIMIZATION,
- OBFUSCATION,
- ACCESS_MODIFICATION,
- ANNOTATION_REMOVAL,
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface KeepEdge {
+ String description() default "";
+
+ KeepBinding[] bindings() default {};
+
+ KeepCondition[] preconditions() default {};
+
+ KeepTarget[] consequences();
}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt b/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt
deleted file mode 100644
index 6e683e5..0000000
--- a/src/keepanno/java/androidx/annotation/keep/KeepEdge.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.TYPE,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class KeepEdge(
- val description: String = "",
-
- // val retention : Array<RetentionPolicy> = [RetentionPolicy.RUNTIME]
- val bindings: Array<KeepBinding> = [],
- val preconditions: Array<KeepCondition> = [],
- val consequences: Array<KeepTarget> = [],
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepForApi.java b/src/keepanno/java/androidx/annotation/keep/KeepForApi.java
new file mode 100644
index 0000000..7ad9e61
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/KeepForApi.java
@@ -0,0 +1,481 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to mark a class, field or method as part of a library API surface.
+ *
+ * <p>When a class is annotated, member patterns can be used to define which members are to be kept.
+ * When no member patterns are specified the default pattern matches all public and protected
+ * members.
+ *
+ * <p>When a member is annotated, the member patterns cannot be used as the annotated member itself
+ * fully defines the item to be kept (i.e., itself).
+ */
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface KeepForApi {
+
+ /**
+ * Optional description to document the reason for this annotation.
+ *
+ * @return The descriptive message. Defaults to no description.
+ */
+ String description() default "";
+
+ /**
+ * Additional targets to be kept as part of the API surface.
+ *
+ * @return List of additional target consequences. Defaults to no additional target consequences.
+ */
+ KeepTarget[] additionalTargets() default {};
+
+ /**
+ * Specify the kind of this item pattern.
+ *
+ * <p>Default kind is {@link KeepItemKind#CLASS_AND_MEMBERS}, meaning the annotated class and/or
+ * member is to be kept. When annotating a class this can be set to {@link
+ * KeepItemKind#ONLY_CLASS} to avoid patterns on any members. That can be useful when the API
+ * members are themselves explicitly annotated.
+ *
+ * <p>It is not possible to use {@link KeepItemKind#ONLY_CLASS} if annotating a member. Also, it
+ * is never valid to use kind {@link KeepItemKind#ONLY_MEMBERS} as the API surface must keep the
+ * class if any member is to be accessible.
+ *
+ * @return The kind for this pattern.
+ */
+ KeepItemKind kind() default KeepItemKind.DEFAULT;
+
+ /**
+ * Define the member-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String memberAnnotatedByClassName() default "";
+
+ /**
+ * Define the member-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> memberAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the member-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern memberAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * @return The member access-flag constraints that must be met.
+ */
+ MemberAccessFlags[] memberAccess() default {};
+
+ /**
+ * Define the method-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassConstant
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String methodAnnotatedByClassName() default "";
+
+ /**
+ * Define the method-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> methodAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the method-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern methodAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the method-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * method-access flags.
+ *
+ * @return The method access-flag constraints that must be met.
+ */
+ MethodAccessFlags[] methodAccess() default {};
+
+ /**
+ * Define the method-name pattern by an exact method name.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodNamePattern` also defining method-name.
+ *
+ * @return The exact method name of the method.
+ */
+ String methodName() default "";
+
+ /**
+ * Define the method-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodName` also defining method-name.
+ *
+ * @return The string pattern of the method name.
+ */
+ StringPattern methodNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the method return-type pattern by a fully qualified type or 'void'.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnTypeConstant
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return The qualified type name of the method return type.
+ */
+ String methodReturnType() default "";
+
+ /**
+ * Define the method return-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return A class constant denoting the type of the method return type.
+ */
+ Class<?> methodReturnTypeConstant() default Object.class;
+
+ /**
+ * Define the method return-type pattern by a type pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypeConstant
+ * </ul>
+ *
+ * @return The pattern of the method return type.
+ */
+ TypePattern methodReturnTypePattern() default @TypePattern(name = "");
+
+ /**
+ * Define the method parameters pattern by a list of fully qualified types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
+ *
+ * @return The list of qualified type names of the method parameters.
+ */
+ String[] methodParameters() default {""};
+
+ /**
+ * Define the method parameters pattern by a list of patterns on types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameters` also defining parameters.
+ *
+ * @return The list of type patterns for the method parameters.
+ */
+ TypePattern[] methodParameterTypePatterns() default {@TypePattern(name = "")};
+
+ /**
+ * Define the field-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassConstant
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String fieldAnnotatedByClassName() default "";
+
+ /**
+ * Define the field-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> fieldAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the field-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern fieldAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the field-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any
+ * field-access flags.
+ *
+ * @return The field access-flag constraints that must be met.
+ */
+ FieldAccessFlags[] fieldAccess() default {};
+
+ /**
+ * Define the field-name pattern by an exact field name.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldNamePattern` also defining field-name.
+ *
+ * @return The exact field name of the field.
+ */
+ String fieldName() default "";
+
+ /**
+ * Define the field-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldName` also defining field-name.
+ *
+ * @return The string pattern of the field name.
+ */
+ StringPattern fieldNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the field-type pattern by a fully qualified type.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldTypeConstant
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The qualified type name for the field type.
+ */
+ String fieldType() default "";
+
+ /**
+ * Define the field-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The class constant for the field type.
+ */
+ Class<?> fieldTypeConstant() default Object.class;
+
+ /**
+ * Define the field-type pattern by a pattern on types.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypeConstant
+ * </ul>
+ *
+ * @return The type pattern for the field type.
+ */
+ TypePattern fieldTypePattern() default @TypePattern(name = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt b/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt
deleted file mode 100644
index 5fa5bf6..0000000
--- a/src/keepanno/java/androidx/annotation/keep/KeepForApi.kt
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * Annotation to mark a class, field or method as part of a library API surface.
- *
- * <p>
- * When a class is annotated, member patterns can be used to define which members are to be kept.
- * When no member patterns are specified the default pattern matches all public and protected
- * members.
- *
- * <p>
- * When a member is annotated, the member patterns cannot be used as the annotated member itself
- * fully defines the item to be kept (i.e., itself).
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.CLASS,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class KeepForApi(
-
- /**
- * Optional description to document the reason for this annotation.
- *
- * @return The descriptive message. Defaults to no description.
- */
- val description: String = "",
-
- /**
- * Additional targets to be kept as part of the API surface.
- *
- * @return List of additional target consequences. Defaults to no additional target consequences.
- */
- val additionalTargets: Array<KeepTarget> = [],
-
- /**
- * Specify the kind of this item pattern.
- *
- * <p>
- * Default kind is {@link KeepItemKind#CLASS_AND_MEMBERS}, meaning the annotated class and/or
- * member is to be kept. When annotating a class this can be set to {@link
- * KeepItemKind#ONLY_CLASS} to avoid patterns on any members. That can be useful when the API
- * members are themselves explicitly annotated.
- *
- * <p>
- * It is not possible to use {@link KeepItemKind#ONLY_CLASS} if annotating a member. Also, it is
- * never valid to use kind {@link KeepItemKind#ONLY_MEMBERS} as the API surface must keep the
- * class if any member is to be accessible.
- *
- * @return The kind for this pattern.
- */
- val kind: KeepItemKind = KeepItemKind.DEFAULT,
-
- /**
- * Define the member-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassConstant
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val memberAnnotatedByClassName: String = "",
-
- /**
- * Define the member-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val memberAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the member-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val memberAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * @return The member access-flag constraints that must be met.
- */
- val memberAccess: Array<MemberAccessFlags> = [],
-
- /**
- * Define the method-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassConstant
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val methodAnnotatedByClassName: String = "",
-
- /**
- * Define the method-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val methodAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the method-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val methodAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the method-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any
- * method-access flags.
- *
- * @return The method access-flag constraints that must be met.
- */
- val methodAccess: Array<MethodAccessFlags> = [],
-
- /**
- * Define the method-name pattern by an exact method name.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodNamePattern` also defining method-name.
- *
- * @return The exact method name of the method.
- */
- val methodName: String = "",
-
- /**
- * Define the method-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodName` also defining method-name.
- *
- * @return The string pattern of the method name.
- */
- val methodNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the method return-type pattern by a fully qualified type or 'void'.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnTypeConstant
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return The qualified type name of the method return type.
- */
- val methodReturnType: String = "",
-
- /**
- * Define the method return-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return A class constant denoting the type of the method return type.
- */
- val methodReturnTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the method return-type pattern by a type pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypeConstant
- * </ul>
- *
- * @return The pattern of the method return type.
- */
- val methodReturnTypePattern: TypePattern = TypePattern(name = ""),
-
- /**
- * Define the method parameters pattern by a list of fully qualified types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
- *
- * @return The list of qualified type names of the method parameters.
- */
- val methodParameters: Array<String> = [""],
-
- /**
- * Define the method parameters pattern by a list of patterns on types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameters` also defining parameters.
- *
- * @return The list of type patterns for the method parameters.
- */
- val methodParameterTypePatterns: Array<TypePattern> = [TypePattern(name = "")],
-
- /**
- * Define the field-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassConstant
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val fieldAnnotatedByClassName: String = "",
-
- /**
- * Define the field-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val fieldAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val fieldAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the field-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field-access
- * flags.
- *
- * @return The field access-flag constraints that must be met.
- */
- val fieldAccess: Array<FieldAccessFlags> = [],
-
- /**
- * Define the field-name pattern by an exact field name.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldNamePattern` also defining field-name.
- *
- * @return The exact field name of the field.
- */
- val fieldName: String = "",
-
- /**
- * Define the field-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldName` also defining field-name.
- *
- * @return The string pattern of the field name.
- */
- val fieldNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the field-type pattern by a fully qualified type.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldTypeConstant
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The qualified type name for the field type.
- */
- val fieldType: String = "",
-
- /**
- * Define the field-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The class constant for the field type.
- */
- val fieldTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-type pattern by a pattern on types.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypeConstant
- * </ul>
- *
- * @return The type pattern for the field type.
- */
- val fieldTypePattern: TypePattern = TypePattern(name = ""),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt b/src/keepanno/java/androidx/annotation/keep/KeepItemKind.java
similarity index 92%
rename from src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt
rename to src/keepanno/java/androidx/annotation/keep/KeepItemKind.java
index 90afbff..5ffc9d7 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepItemKind.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepItemKind.java
@@ -18,9 +18,9 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-enum class KeepItemKind {
+public enum KeepItemKind {
ONLY_CLASS,
ONLY_MEMBERS,
ONLY_METHODS,
@@ -28,5 +28,5 @@
CLASS_AND_MEMBERS,
CLASS_AND_METHODS,
CLASS_AND_FIELDS,
- DEFAULT,
+ DEFAULT
}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepOption.kt b/src/keepanno/java/androidx/annotation/keep/KeepOption.java
similarity index 93%
rename from src/keepanno/java/androidx/annotation/keep/KeepOption.kt
rename to src/keepanno/java/androidx/annotation/keep/KeepOption.java
index 13ef7f6..b635d1c 100644
--- a/src/keepanno/java/androidx/annotation/keep/KeepOption.kt
+++ b/src/keepanno/java/androidx/annotation/keep/KeepOption.java
@@ -18,9 +18,9 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-enum class KeepOption {
+public enum KeepOption {
SHRINKING,
OPTIMIZATION,
OBFUSCATION,
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepTarget.java b/src/keepanno/java/androidx/annotation/keep/KeepTarget.java
new file mode 100644
index 0000000..96196a9
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/KeepTarget.java
@@ -0,0 +1,842 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A target for a keep edge.
+ *
+ * <p>The target denotes an item along with options for what to keep. An item can be:
+ *
+ * <ul>
+ * <li>a pattern on classes;
+ * <li>a pattern on methods; or
+ * <li>a pattern on fields.
+ * </ul>
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface KeepTarget {
+
+ /**
+ * Specify the kind of this item pattern.
+ *
+ * <p>Possible values are:
+ *
+ * <ul>
+ * <li>{@link KeepItemKind#ONLY_CLASS}
+ * <li>{@link KeepItemKind#ONLY_MEMBERS}
+ * <li>{@link KeepItemKind#ONLY_METHODS}
+ * <li>{@link KeepItemKind#ONLY_FIELDS}
+ * <li>{@link KeepItemKind#CLASS_AND_MEMBERS}
+ * <li>{@link KeepItemKind#CLASS_AND_METHODS}
+ * <li>{@link KeepItemKind#CLASS_AND_FIELDS}
+ * </ul>
+ *
+ * <p>If unspecified the default kind for an item depends on its member patterns:
+ *
+ * <ul>
+ * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined
+ * <li>{@link KeepItemKind#ONLY_METHODS} if method patterns are defined
+ * <li>{@link KeepItemKind#ONLY_FIELDS} if field patterns are defined
+ * <li>{@link KeepItemKind#ONLY_MEMBERS} otherwise.
+ * </ul>
+ *
+ * @return The kind for this pattern.
+ */
+ KeepItemKind kind() default KeepItemKind.DEFAULT;
+
+ /**
+ * Define the usage constraints of the target.
+ *
+ * <p>The specified constraints must remain valid for the target.
+ *
+ * <p>The default constraints depend on the kind of the target. For all targets the default
+ * constraints include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#LOOKUP}
+ * <li>{@link KeepConstraint#NAME}
+ * <li>{@link KeepConstraint#VISIBILITY_RELAX}
+ * </ul>
+ *
+ * <p>For classes the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#CLASS_INSTANTIATE}
+ * </ul>
+ *
+ * <p>For methods the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#METHOD_INVOKE}
+ * </ul>
+ *
+ * <p>For fields the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#FIELD_GET}
+ * <li>{@link KeepConstraint#FIELD_SET}
+ * </ul>
+ *
+ * <p>Mutually exclusive with the property `constraintAdditions` also defining constraints.
+ *
+ * @return Usage constraints for the target.
+ */
+ KeepConstraint[] constraints() default {};
+
+ /**
+ * Add additional usage constraints of the target.
+ *
+ * <p>The specified constraints must remain valid for the target in addition to the default
+ * constraints.
+ *
+ * <p>The default constraints are documented in {@link #constraints}
+ *
+ * <p>Mutually exclusive with the property `constraints` also defining constraints.
+ *
+ * @return Additional usage constraints for the target.
+ */
+ KeepConstraint[] constraintAdditions() default {};
+
+ /**
+ * Patterns for annotations that must remain on the item.
+ *
+ * <p>The annotations matching any of the patterns must remain on the item if the annotation types
+ * remain in the program.
+ *
+ * <p>Note that if the annotation types themselves are unused/removed, then their references on
+ * the item will be removed too. If the annotation types themselves are used reflectively then
+ * they too need a keep annotation or rule to ensure they remain in the program.
+ *
+ * <p>By default no annotation patterns are defined and no annotations are required to remain.
+ *
+ * @return Annotation patterns
+ */
+ AnnotationPattern[] constrainAnnotations() default {};
+
+ /**
+ * Define the class pattern by reference to a binding.
+ *
+ * <p>Mutually exclusive with the following other properties defining class:
+ *
+ * <ul>
+ * <li>className
+ * <li>classConstant
+ * <li>classNamePattern
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassConstant
+ * <li>classAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class.
+ *
+ * @return The name of the binding that defines the class.
+ */
+ String classFromBinding() default "";
+
+ /**
+ * Define the class-name pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>classConstant
+ * <li>classNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The qualified class name that defines the class.
+ */
+ String className() default "";
+
+ /**
+ * Define the class-name pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>className
+ * <li>classNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The class-constant that defines the class.
+ */
+ Class<?> classConstant() default Object.class;
+
+ /**
+ * Define the class-name pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-name:
+ *
+ * <ul>
+ * <li>className
+ * <li>classConstant
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class name.
+ *
+ * @return The class-name pattern that defines the class.
+ */
+ ClassNamePattern classNamePattern() default @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the instance-of pattern as classes that are instances of the fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The qualified class name that defines what instance-of the class must be.
+ */
+ String instanceOfClassName() default "";
+
+ /**
+ * Define the instance-of pattern as classes that are instances of the fully qualified class name.
+ *
+ * <p>The pattern is exclusive in that it does not match classes that are instances of the
+ * pattern, but only those that are instances of classes that are subclasses of the pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The qualified class name that defines what instance-of the class must be.
+ */
+ String instanceOfClassNameExclusive() default "";
+
+ /**
+ * Define the instance-of pattern as classes that are instances the referenced Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstantExclusive
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The class constant that defines what instance-of the class must be.
+ */
+ Class<?> instanceOfClassConstant() default Object.class;
+
+ /**
+ * Define the instance-of pattern as classes that are instances the referenced Class constant.
+ *
+ * <p>The pattern is exclusive in that it does not match classes that are instances of the
+ * pattern, but only those that are instances of classes that are subclasses of the pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfPattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The class constant that defines what instance-of the class must be.
+ */
+ Class<?> instanceOfClassConstantExclusive() default Object.class;
+
+ /**
+ * Define the instance-of with a pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining instance-of:
+ *
+ * <ul>
+ * <li>instanceOfClassName
+ * <li>instanceOfClassNameExclusive
+ * <li>instanceOfClassConstant
+ * <li>instanceOfClassConstantExclusive
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class instance.
+ *
+ * @return The pattern that defines what instance-of the class must be.
+ */
+ InstanceOfPattern instanceOfPattern() default @InstanceOfPattern();
+
+ /**
+ * Define the class-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassConstant
+ * <li>classAnnotatedByClassNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String classAnnotatedByClassName() default "";
+
+ /**
+ * Define the class-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassNamePattern
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> classAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the class-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining class-annotated-by:
+ *
+ * <ul>
+ * <li>classAnnotatedByClassName
+ * <li>classAnnotatedByClassConstant
+ * <li>classFromBinding
+ * </ul>
+ *
+ * <p>If none are specified the default is to match any class regardless of what the class is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern classAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member pattern in full by a reference to a binding.
+ *
+ * <p>Mutually exclusive with all other class and member pattern properties. When a member binding
+ * is referenced this item is defined to be that item, including its class and member patterns.
+ *
+ * @return The binding name that defines the member.
+ */
+ String memberFromBinding() default "";
+
+ /**
+ * Define the member-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String memberAnnotatedByClassName() default "";
+
+ /**
+ * Define the member-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> memberAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the member-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern memberAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>Mutually exclusive with the property `memberFromBinding` also defining member-access.
+ *
+ * @return The member access-flag constraints that must be met.
+ */
+ MemberAccessFlags[] memberAccess() default {};
+
+ /**
+ * Define the method-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassConstant
+ * <li>methodAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String methodAnnotatedByClassName() default "";
+
+ /**
+ * Define the method-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> methodAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the method-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern methodAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the method-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * method-access flags.
+ *
+ * <p>Mutually exclusive with the property `memberFromBinding` also defining method-access.
+ *
+ * @return The method access-flag constraints that must be met.
+ */
+ MethodAccessFlags[] methodAccess() default {};
+
+ /**
+ * Define the method-name pattern by an exact method name.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-name:
+ *
+ * <ul>
+ * <li>methodNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The exact method name of the method.
+ */
+ String methodName() default "";
+
+ /**
+ * Define the method-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-name:
+ *
+ * <ul>
+ * <li>methodName
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The string pattern of the method name.
+ */
+ StringPattern methodNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the method return-type pattern by a fully qualified type or 'void'.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnTypeConstant
+ * <li>methodReturnTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The qualified type name of the method return type.
+ */
+ String methodReturnType() default "";
+
+ /**
+ * Define the method return-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return A class constant denoting the type of the method return type.
+ */
+ Class<?> methodReturnTypeConstant() default Object.class;
+
+ /**
+ * Define the method return-type pattern by a type pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypeConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The pattern of the method return type.
+ */
+ TypePattern methodReturnTypePattern() default @TypePattern(name = "");
+
+ /**
+ * Define the method parameters pattern by a list of fully qualified types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the following other properties defining parameters:
+ *
+ * <ul>
+ * <li>methodParameterTypePatterns
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The list of qualified type names of the method parameters.
+ */
+ String[] methodParameters() default {""};
+
+ /**
+ * Define the method parameters pattern by a list of patterns on types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the following other properties defining parameters:
+ *
+ * <ul>
+ * <li>methodParameters
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The list of type patterns for the method parameters.
+ */
+ TypePattern[] methodParameterTypePatterns() default {@TypePattern(name = "")};
+
+ /**
+ * Define the field-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassConstant
+ * <li>fieldAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String fieldAnnotatedByClassName() default "";
+
+ /**
+ * Define the field-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> fieldAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the field-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern fieldAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the field-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any
+ * field-access flags.
+ *
+ * <p>Mutually exclusive with the property `memberFromBinding` also defining field-access.
+ *
+ * @return The field access-flag constraints that must be met.
+ */
+ FieldAccessFlags[] fieldAccess() default {};
+
+ /**
+ * Define the field-name pattern by an exact field name.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-name:
+ *
+ * <ul>
+ * <li>fieldNamePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The exact field name of the field.
+ */
+ String fieldName() default "";
+
+ /**
+ * Define the field-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-name:
+ *
+ * <ul>
+ * <li>fieldName
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The string pattern of the field name.
+ */
+ StringPattern fieldNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the field-type pattern by a fully qualified type.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldTypeConstant
+ * <li>fieldTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The qualified type name for the field type.
+ */
+ String fieldType() default "";
+
+ /**
+ * Define the field-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypePattern
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The class constant for the field type.
+ */
+ Class<?> fieldTypeConstant() default Object.class;
+
+ /**
+ * Define the field-type pattern by a pattern on types.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypeConstant
+ * <li>memberFromBinding
+ * </ul>
+ *
+ * @return The type pattern for the field type.
+ */
+ TypePattern fieldTypePattern() default @TypePattern(name = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt b/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt
deleted file mode 100644
index 7dbb4a2..0000000
--- a/src/keepanno/java/androidx/annotation/keep/KeepTarget.kt
+++ /dev/null
@@ -1,906 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * A target for a keep edge.
- *
- * <p>
- * The target denotes an item along with options for what to keep. An item can be:
- * <ul>
- * <li>a pattern on classes;
- * <li>a pattern on methods; or
- * <li>a pattern on fields.
- * </ul>
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class KeepTarget(
-
- /**
- * Specify the kind of this item pattern.
- *
- * <p>
- * Possible values are:
- * <ul>
- * <li>{@link KeepItemKind#ONLY_CLASS}
- * <li>{@link KeepItemKind#ONLY_MEMBERS}
- * <li>{@link KeepItemKind#ONLY_METHODS}
- * <li>{@link KeepItemKind#ONLY_FIELDS}
- * <li>{@link KeepItemKind#CLASS_AND_MEMBERS}
- * <li>{@link KeepItemKind#CLASS_AND_METHODS}
- * <li>{@link KeepItemKind#CLASS_AND_FIELDS}
- * </ul>
- *
- * <p>
- * If unspecified the default kind for an item depends on its member patterns:
- * <ul>
- * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined
- * <li>{@link KeepItemKind#ONLY_METHODS} if method patterns are defined
- * <li>{@link KeepItemKind#ONLY_FIELDS} if field patterns are defined
- * <li>{@link KeepItemKind#ONLY_MEMBERS} otherwise.
- * </ul>
- *
- * @return The kind for this pattern.
- */
- val kind: KeepItemKind = KeepItemKind.DEFAULT,
-
- /**
- * Define the usage constraints of the target.
- *
- * <p>
- * The specified constraints must remain valid for the target.
- *
- * <p>
- * The default constraints depend on the kind of the target. For all targets the default
- * constraints include:
- * <ul>
- * <li>{@link KeepConstraint#LOOKUP}
- * <li>{@link KeepConstraint#NAME}
- * <li>{@link KeepConstraint#VISIBILITY_RELAX}
- * </ul>
- *
- * <p>
- * For classes the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#CLASS_INSTANTIATE}
- * </ul>
- *
- * <p>
- * For methods the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#METHOD_INVOKE}
- * </ul>
- *
- * <p>
- * For fields the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#FIELD_GET}
- * <li>{@link KeepConstraint#FIELD_SET}
- * </ul>
- *
- * <p>
- * Mutually exclusive with the property `constraintAdditions` also defining constraints.
- *
- * @return Usage constraints for the target.
- */
- val constraints: Array<KeepConstraint> = [],
-
- /**
- * Add additional usage constraints of the target.
- *
- * <p>
- * The specified constraints must remain valid for the target in addition to the default
- * constraints.
- *
- * <p>
- * The default constraints are documented in {@link #constraints}
- *
- * <p>
- * Mutually exclusive with the property `constraints` also defining constraints.
- *
- * @return Additional usage constraints for the target.
- */
- val constraintAdditions: Array<KeepConstraint> = [],
-
- /**
- * Patterns for annotations that must remain on the item.
- *
- * <p>
- * The annotations matching any of the patterns must remain on the item if the annotation types
- * remain in the program.
- *
- * <p>
- * Note that if the annotation types themselves are unused/removed, then their references on the
- * item will be removed too. If the annotation types themselves are used reflectively then they
- * too need a keep annotation or rule to ensure they remain in the program.
- *
- * <p>
- * By default no annotation patterns are defined and no annotations are required to remain.
- *
- * @return Annotation patterns
- */
- val constrainAnnotations: Array<AnnotationPattern> = [],
-
- /**
- * Define the class pattern by reference to a binding.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class:
- * <ul>
- * <li>className
- * <li>classConstant
- * <li>classNamePattern
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassConstant
- * <li>classAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class.
- *
- * @return The name of the binding that defines the class.
- */
- val classFromBinding: String = "",
-
- /**
- * Define the class-name pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>classConstant
- * <li>classNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The qualified class name that defines the class.
- */
- val className: String = "",
-
- /**
- * Define the class-name pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>className
- * <li>classNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The class-constant that defines the class.
- */
- val classConstant: KClass<*> = Object::class,
-
- /**
- * Define the class-name pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-name:
- * <ul>
- * <li>className
- * <li>classConstant
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class name.
- *
- * @return The class-name pattern that defines the class.
- */
- val classNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the instance-of pattern as classes that are instances of the fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The qualified class name that defines what instance-of the class must be.
- */
- val instanceOfClassName: String = "",
-
- /**
- * Define the instance-of pattern as classes that are instances of the fully qualified class name.
- *
- * <p>
- * The pattern is exclusive in that it does not match classes that are instances of the pattern,
- * but only those that are instances of classes that are subclasses of the pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The qualified class name that defines what instance-of the class must be.
- */
- val instanceOfClassNameExclusive: String = "",
-
- /**
- * Define the instance-of pattern as classes that are instances the referenced Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstantExclusive
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The class constant that defines what instance-of the class must be.
- */
- val instanceOfClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the instance-of pattern as classes that are instances the referenced Class constant.
- *
- * <p>
- * The pattern is exclusive in that it does not match classes that are instances of the pattern,
- * but only those that are instances of classes that are subclasses of the pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfPattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The class constant that defines what instance-of the class must be.
- */
- val instanceOfClassConstantExclusive: KClass<*> = Object::class,
-
- /**
- * Define the instance-of with a pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining instance-of:
- * <ul>
- * <li>instanceOfClassName
- * <li>instanceOfClassNameExclusive
- * <li>instanceOfClassConstant
- * <li>instanceOfClassConstantExclusive
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class instance.
- *
- * @return The pattern that defines what instance-of the class must be.
- */
- val instanceOfPattern: InstanceOfPattern = InstanceOfPattern(),
-
- /**
- * Define the class-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassConstant
- * <li>classAnnotatedByClassNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val classAnnotatedByClassName: String = "",
-
- /**
- * Define the class-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassNamePattern
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val classAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the class-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining class-annotated-by:
- * <ul>
- * <li>classAnnotatedByClassName
- * <li>classAnnotatedByClassConstant
- * <li>classFromBinding
- * </ul>
- *
- * <p>
- * If none are specified the default is to match any class regardless of what the class is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val classAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member pattern in full by a reference to a binding.
- *
- * <p>
- * Mutually exclusive with all other class and member pattern properties. When a member binding is
- * referenced this item is defined to be that item, including its class and member patterns.
- *
- * @return The binding name that defines the member.
- */
- val memberFromBinding: String = "",
-
- /**
- * Define the member-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassConstant
- * <li>memberAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val memberAnnotatedByClassName: String = "",
-
- /**
- * Define the member-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val memberAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the member-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassConstant
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val memberAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * Mutually exclusive with the property `memberFromBinding` also defining member-access.
- *
- * @return The member access-flag constraints that must be met.
- */
- val memberAccess: Array<MemberAccessFlags> = [],
-
- /**
- * Define the method-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassConstant
- * <li>methodAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val methodAnnotatedByClassName: String = "",
-
- /**
- * Define the method-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val methodAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the method-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassConstant
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val methodAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the method-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any
- * method-access flags.
- *
- * <p>
- * Mutually exclusive with the property `memberFromBinding` also defining method-access.
- *
- * @return The method access-flag constraints that must be met.
- */
- val methodAccess: Array<MethodAccessFlags> = [],
-
- /**
- * Define the method-name pattern by an exact method name.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-name:
- * <ul>
- * <li>methodNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The exact method name of the method.
- */
- val methodName: String = "",
-
- /**
- * Define the method-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-name:
- * <ul>
- * <li>methodName
- * <li>memberFromBinding
- * </ul>
- *
- * @return The string pattern of the method name.
- */
- val methodNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the method return-type pattern by a fully qualified type or 'void'.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnTypeConstant
- * <li>methodReturnTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The qualified type name of the method return type.
- */
- val methodReturnType: String = "",
-
- /**
- * Define the method return-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return A class constant denoting the type of the method return type.
- */
- val methodReturnTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the method return-type pattern by a type pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypeConstant
- * <li>memberFromBinding
- * </ul>
- *
- * @return The pattern of the method return type.
- */
- val methodReturnTypePattern: TypePattern = TypePattern(name = ""),
-
- /**
- * Define the method parameters pattern by a list of fully qualified types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the following other properties defining parameters:
- * <ul>
- * <li>methodParameterTypePatterns
- * <li>memberFromBinding
- * </ul>
- *
- * @return The list of qualified type names of the method parameters.
- */
- val methodParameters: Array<String> = [""],
-
- /**
- * Define the method parameters pattern by a list of patterns on types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the following other properties defining parameters:
- * <ul>
- * <li>methodParameters
- * <li>memberFromBinding
- * </ul>
- *
- * @return The list of type patterns for the method parameters.
- */
- val methodParameterTypePatterns: Array<TypePattern> = [TypePattern(name = "")],
-
- /**
- * Define the field-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassConstant
- * <li>fieldAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val fieldAnnotatedByClassName: String = "",
-
- /**
- * Define the field-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val fieldAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassConstant
- * <li>memberFromBinding
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val fieldAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the field-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field-access
- * flags.
- *
- * <p>
- * Mutually exclusive with the property `memberFromBinding` also defining field-access.
- *
- * @return The field access-flag constraints that must be met.
- */
- val fieldAccess: Array<FieldAccessFlags> = [],
-
- /**
- * Define the field-name pattern by an exact field name.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-name:
- * <ul>
- * <li>fieldNamePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The exact field name of the field.
- */
- val fieldName: String = "",
-
- /**
- * Define the field-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-name:
- * <ul>
- * <li>fieldName
- * <li>memberFromBinding
- * </ul>
- *
- * @return The string pattern of the field name.
- */
- val fieldNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the field-type pattern by a fully qualified type.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldTypeConstant
- * <li>fieldTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The qualified type name for the field type.
- */
- val fieldType: String = "",
-
- /**
- * Define the field-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypePattern
- * <li>memberFromBinding
- * </ul>
- *
- * @return The class constant for the field type.
- */
- val fieldTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-type pattern by a pattern on types.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypeConstant
- * <li>memberFromBinding
- * </ul>
- *
- * @return The type pattern for the field type.
- */
- val fieldTypePattern: TypePattern = TypePattern(name = ""),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.java
similarity index 93%
rename from src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt
rename to src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.java
index 4985630..dd6c1d6 100644
--- a/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/MemberAccessFlags.java
@@ -18,7 +18,7 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
/**
* Valid matches on member access flags and their negations.
@@ -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 MemberAccessFlags {
PUBLIC,
NON_PUBLIC,
PROTECTED,
@@ -40,5 +40,5 @@
FINAL,
NON_FINAL,
SYNTHETIC,
- NON_SYNTHETIC,
+ NON_SYNTHETIC
}
diff --git a/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt b/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.java
similarity index 94%
rename from src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt
rename to src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.java
index a3fa2f7..9b9fca0 100644
--- a/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.kt
+++ b/src/keepanno/java/androidx/annotation/keep/MethodAccessFlags.java
@@ -18,7 +18,7 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
/**
* Valid matches on method access flags and their negations.
@@ -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 MethodAccessFlags {
// General member flags.
PUBLIC,
NON_PUBLIC,
@@ -53,5 +53,5 @@
ABSTRACT,
NON_ABSTRACT,
STRICT_FP,
- NON_STRICT_FP,
+ NON_STRICT_FP
}
diff --git a/src/keepanno/java/androidx/annotation/keep/StringPattern.java b/src/keepanno/java/androidx/annotation/keep/StringPattern.java
new file mode 100644
index 0000000..0a0d803
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/StringPattern.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A pattern structure for matching strings.
+ *
+ * <p>If no properties are set, the default pattern matches any string.
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface StringPattern {
+
+ /**
+ * Exact string content.
+ *
+ * <p>For example, {@code "foo"} or {@code "java.lang.String"}.
+ *
+ * <p>Mutually exclusive with the following other properties defining string-exact-pattern:
+ *
+ * <ul>
+ * <li>startsWith
+ * <li>endsWith
+ * </ul>
+ */
+ String exact() default "";
+
+ /**
+ * Matches strings beginning with the given prefix.
+ *
+ * <p>For example, {@code "get"} to match strings such as {@code "getMyValue"}.
+ *
+ * <p>Mutually exclusive with the property `exact` also defining string-prefix-pattern.
+ */
+ String startsWith() default "";
+
+ /**
+ * Matches strings ending with the given suffix.
+ *
+ * <p>For example, {@code "Setter"} to match strings such as {@code "myValueSetter"}.
+ *
+ * <p>Mutually exclusive with the property `exact` also defining string-suffix-pattern.
+ */
+ String endsWith() default "";
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/StringPattern.kt b/src/keepanno/java/androidx/annotation/keep/StringPattern.kt
deleted file mode 100644
index bb872ec..0000000
--- a/src/keepanno/java/androidx/annotation/keep/StringPattern.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-
-/**
- * A pattern structure for matching strings.
- *
- * <p>
- * If no properties are set, the default pattern matches any string.
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class StringPattern(
-
- /**
- * Exact string content.
- *
- * <p>
- * For example, {@code "foo"} or {@code "java.lang.String"}.
- *
- * <p>
- * Mutually exclusive with the following other properties defining string-exact-pattern:
- * <ul>
- * <li>startsWith
- * <li>endsWith
- * </ul>
- */
- val exact: String = "",
-
- /**
- * Matches strings beginning with the given prefix.
- *
- * <p>
- * For example, {@code "get"} to match strings such as {@code "getMyValue"}.
- *
- * <p>
- * Mutually exclusive with the property `exact` also defining string-prefix-pattern.
- */
- val startsWith: String = "",
-
- /**
- * Matches strings ending with the given suffix.
- *
- * <p>
- * For example, {@code "Setter"} to match strings such as {@code "myValueSetter"}.
- *
- * <p>
- * Mutually exclusive with the property `exact` also defining string-suffix-pattern.
- */
- val endsWith: String = "",
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/TypePattern.java b/src/keepanno/java/androidx/annotation/keep/TypePattern.java
new file mode 100644
index 0000000..71b41aa
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/TypePattern.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A pattern structure for matching types.
+ *
+ * <p>If no properties are set, the default pattern matches any type.
+ *
+ * <p>All properties on this annotation are mutually exclusive.
+ */
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface TypePattern {
+
+ /**
+ * Exact type name as a string.
+ *
+ * <p>For example, {@code "long"} or {@code "java.lang.String"}.
+ *
+ * <p>Mutually exclusive with the following other properties defining type-pattern:
+ *
+ * <ul>
+ * <li>constant
+ * <li>classNamePattern
+ * <li>instanceOfPattern
+ * </ul>
+ */
+ String name() default "";
+
+ /**
+ * Exact type from a class constant.
+ *
+ * <p>For example, {@code String.class}.
+ *
+ * <p>Mutually exclusive with the following other properties defining type-pattern:
+ *
+ * <ul>
+ * <li>name
+ * <li>classNamePattern
+ * <li>instanceOfPattern
+ * </ul>
+ */
+ Class<?> constant() default Object.class;
+
+ /**
+ * Classes matching the class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining type-pattern:
+ *
+ * <ul>
+ * <li>name
+ * <li>constant
+ * <li>instanceOfPattern
+ * </ul>
+ */
+ ClassNamePattern classNamePattern() default @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the instance-of with a pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining type-pattern:
+ *
+ * <ul>
+ * <li>name
+ * <li>constant
+ * <li>classNamePattern
+ * </ul>
+ *
+ * @return The pattern that defines what instance-of the class must be.
+ */
+ InstanceOfPattern instanceOfPattern() default @InstanceOfPattern();
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/TypePattern.kt b/src/keepanno/java/androidx/annotation/keep/TypePattern.kt
deleted file mode 100644
index 0e87702..0000000
--- a/src/keepanno/java/androidx/annotation/keep/TypePattern.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * A pattern structure for matching types.
- *
- * <p>
- * If no properties are set, the default pattern matches any type.
- *
- * <p>
- * All properties on this annotation are mutually exclusive.
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(AnnotationTarget.ANNOTATION_CLASS)
-annotation class TypePattern(
-
- /**
- * Exact type name as a string.
- *
- * <p>
- * For example, {@code "long"} or {@code "java.lang.String"}.
- *
- * <p>
- * Mutually exclusive with the following other properties defining type-pattern:
- * <ul>
- * <li>constant
- * <li>classNamePattern
- * <li>instanceOfPattern
- * </ul>
- */
- val name: String = "",
-
- /**
- * Exact type from a class constant.
- *
- * <p>
- * For example, {@code String.class}.
- *
- * <p>
- * Mutually exclusive with the following other properties defining type-pattern:
- * <ul>
- * <li>name
- * <li>classNamePattern
- * <li>instanceOfPattern
- * </ul>
- */
- val constant: KClass<*> = Object::class,
-
- /**
- * Classes matching the class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining type-pattern:
- * <ul>
- * <li>name
- * <li>constant
- * <li>instanceOfPattern
- * </ul>
- */
- val classNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the instance-of with a pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining type-pattern:
- * <ul>
- * <li>name
- * <li>constant
- * <li>classNamePattern
- * </ul>
- *
- * @return The pattern that defines what instance-of the class must be.
- */
- val instanceOfPattern: InstanceOfPattern = InstanceOfPattern(),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/UsedByNative.java b/src/keepanno/java/androidx/annotation/keep/UsedByNative.java
new file mode 100644
index 0000000..955bc95
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/UsedByNative.java
@@ -0,0 +1,571 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to mark a class, field or method as being accessed from native code via JNI.
+ *
+ * <p>Note: Before using this annotation, consider if instead you can annotate the code that is
+ * doing reflection with {@link UsesReflection}. Annotating the reflecting code is generally more
+ * clear and maintainable, and it also naturally gives rise to edges that describe just the
+ * reflected aspects of the program. The {@link UsedByReflection} annotation is suitable for cases
+ * where the reflecting code is not under user control, or in migrating away from rules.
+ *
+ * <p>When a class is annotated, member patterns can be used to define which members are to be kept.
+ * When no member patterns are specified the default pattern is to match just the class.
+ *
+ * <p>When a member is annotated, the member patterns cannot be used as the annotated member itself
+ * fully defines the item to be kept (i.e., itself).
+ */
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface UsedByNative {
+
+ /**
+ * Optional description to document the reason for this annotation.
+ *
+ * @return The descriptive message. Defaults to no description.
+ */
+ String description() default "";
+
+ /**
+ * Conditions that should be satisfied for the annotation to be in effect.
+ *
+ * @return The list of preconditions. Defaults to no conditions, thus trivially/unconditionally
+ * satisfied.
+ */
+ KeepCondition[] preconditions() default {};
+
+ /**
+ * Additional targets to be kept in addition to the annotated class/members.
+ *
+ * @return List of additional target consequences. Defaults to no additional target consequences.
+ */
+ KeepTarget[] additionalTargets() default {};
+
+ /**
+ * Specify the kind of this item pattern.
+ *
+ * <p>If unspecified the default kind depends on the annotated item.
+ *
+ * <p>When annotating a class the default kind is:
+ *
+ * <ul>
+ * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined;
+ * <li>{@link KeepItemKind#CLASS_AND_METHODS} if method patterns are defined;
+ * <li>{@link KeepItemKind#CLASS_AND_FIELDS} if field patterns are defined;
+ * <li>{@link KeepItemKind#CLASS_AND_MEMBERS} otherwise.
+ * </ul>
+ *
+ * <p>When annotating a method the default kind is: {@link KeepItemKind#ONLY_METHODS}
+ *
+ * <p>When annotating a field the default kind is: {@link KeepItemKind#ONLY_FIELDS}
+ *
+ * <p>It is not possible to use {@link KeepItemKind#ONLY_CLASS} if annotating a member.
+ *
+ * @return The kind for this pattern.
+ */
+ KeepItemKind kind() default KeepItemKind.DEFAULT;
+
+ /**
+ * Define the usage constraints of the target.
+ *
+ * <p>The specified constraints must remain valid for the target.
+ *
+ * <p>The default constraints depend on the kind of the target. For all targets the default
+ * constraints include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#LOOKUP}
+ * <li>{@link KeepConstraint#NAME}
+ * <li>{@link KeepConstraint#VISIBILITY_RELAX}
+ * </ul>
+ *
+ * <p>For classes the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#CLASS_INSTANTIATE}
+ * </ul>
+ *
+ * <p>For methods the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#METHOD_INVOKE}
+ * </ul>
+ *
+ * <p>For fields the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#FIELD_GET}
+ * <li>{@link KeepConstraint#FIELD_SET}
+ * </ul>
+ *
+ * <p>Mutually exclusive with the property `constraintAdditions` also defining constraints.
+ *
+ * @return Usage constraints for the target.
+ */
+ KeepConstraint[] constraints() default {};
+
+ /**
+ * Add additional usage constraints of the target.
+ *
+ * <p>The specified constraints must remain valid for the target in addition to the default
+ * constraints.
+ *
+ * <p>The default constraints are documented in {@link #constraints}
+ *
+ * <p>Mutually exclusive with the property `constraints` also defining constraints.
+ *
+ * @return Additional usage constraints for the target.
+ */
+ KeepConstraint[] constraintAdditions() default {};
+
+ /**
+ * Patterns for annotations that must remain on the item.
+ *
+ * <p>The annotations matching any of the patterns must remain on the item if the annotation types
+ * remain in the program.
+ *
+ * <p>Note that if the annotation types themselves are unused/removed, then their references on
+ * the item will be removed too. If the annotation types themselves are used reflectively then
+ * they too need a keep annotation or rule to ensure they remain in the program.
+ *
+ * <p>By default no annotation patterns are defined and no annotations are required to remain.
+ *
+ * @return Annotation patterns
+ */
+ AnnotationPattern[] constrainAnnotations() default {};
+
+ /**
+ * Define the member-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String memberAnnotatedByClassName() default "";
+
+ /**
+ * Define the member-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> memberAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the member-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern memberAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * @return The member access-flag constraints that must be met.
+ */
+ MemberAccessFlags[] memberAccess() default {};
+
+ /**
+ * Define the method-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassConstant
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String methodAnnotatedByClassName() default "";
+
+ /**
+ * Define the method-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> methodAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the method-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern methodAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the method-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * method-access flags.
+ *
+ * @return The method access-flag constraints that must be met.
+ */
+ MethodAccessFlags[] methodAccess() default {};
+
+ /**
+ * Define the method-name pattern by an exact method name.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodNamePattern` also defining method-name.
+ *
+ * @return The exact method name of the method.
+ */
+ String methodName() default "";
+
+ /**
+ * Define the method-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodName` also defining method-name.
+ *
+ * @return The string pattern of the method name.
+ */
+ StringPattern methodNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the method return-type pattern by a fully qualified type or 'void'.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnTypeConstant
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return The qualified type name of the method return type.
+ */
+ String methodReturnType() default "";
+
+ /**
+ * Define the method return-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return A class constant denoting the type of the method return type.
+ */
+ Class<?> methodReturnTypeConstant() default Object.class;
+
+ /**
+ * Define the method return-type pattern by a type pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypeConstant
+ * </ul>
+ *
+ * @return The pattern of the method return type.
+ */
+ TypePattern methodReturnTypePattern() default @TypePattern(name = "");
+
+ /**
+ * Define the method parameters pattern by a list of fully qualified types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
+ *
+ * @return The list of qualified type names of the method parameters.
+ */
+ String[] methodParameters() default {""};
+
+ /**
+ * Define the method parameters pattern by a list of patterns on types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameters` also defining parameters.
+ *
+ * @return The list of type patterns for the method parameters.
+ */
+ TypePattern[] methodParameterTypePatterns() default {@TypePattern(name = "")};
+
+ /**
+ * Define the field-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassConstant
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String fieldAnnotatedByClassName() default "";
+
+ /**
+ * Define the field-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> fieldAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the field-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern fieldAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the field-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any
+ * field-access flags.
+ *
+ * @return The field access-flag constraints that must be met.
+ */
+ FieldAccessFlags[] fieldAccess() default {};
+
+ /**
+ * Define the field-name pattern by an exact field name.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldNamePattern` also defining field-name.
+ *
+ * @return The exact field name of the field.
+ */
+ String fieldName() default "";
+
+ /**
+ * Define the field-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldName` also defining field-name.
+ *
+ * @return The string pattern of the field name.
+ */
+ StringPattern fieldNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the field-type pattern by a fully qualified type.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldTypeConstant
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The qualified type name for the field type.
+ */
+ String fieldType() default "";
+
+ /**
+ * Define the field-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The class constant for the field type.
+ */
+ Class<?> fieldTypeConstant() default Object.class;
+
+ /**
+ * Define the field-type pattern by a pattern on types.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypeConstant
+ * </ul>
+ *
+ * @return The type pattern for the field type.
+ */
+ TypePattern fieldTypePattern() default @TypePattern(name = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt b/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt
deleted file mode 100644
index 677a344..0000000
--- a/src/keepanno/java/androidx/annotation/keep/UsedByNative.kt
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * Annotation to mark a class, field or method as being accessed from native code via JNI.
- *
- * <p>
- * Note: Before using this annotation, consider if instead you can annotate the code that is doing
- * reflection with {@link UsesReflection}. Annotating the reflecting code is generally more clear
- * and maintainable, and it also naturally gives rise to edges that describe just the reflected
- * aspects of the program. The {@link UsedByReflection} annotation is suitable for cases where the
- * reflecting code is not under user control, or in migrating away from rules.
- *
- * <p>
- * When a class is annotated, member patterns can be used to define which members are to be kept.
- * When no member patterns are specified the default pattern is to match just the class.
- *
- * <p>
- * When a member is annotated, the member patterns cannot be used as the annotated member itself
- * fully defines the item to be kept (i.e., itself).
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.CLASS,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class UsedByNative(
-
- /**
- * Optional description to document the reason for this annotation.
- *
- * @return The descriptive message. Defaults to no description.
- */
- val description: String = "",
-
- /**
- * Conditions that should be satisfied for the annotation to be in effect.
- *
- * @return The list of preconditions. Defaults to no conditions, thus trivially/unconditionally
- * satisfied.
- */
- val preconditions: Array<KeepCondition> = [],
-
- /**
- * Additional targets to be kept in addition to the annotated class/members.
- *
- * @return List of additional target consequences. Defaults to no additional target consequences.
- */
- val additionalTargets: Array<KeepTarget> = [],
-
- /**
- * Specify the kind of this item pattern.
- *
- * <p>
- * If unspecified the default kind depends on the annotated item.
- *
- * <p>
- * When annotating a class the default kind is:
- * <ul>
- * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined;
- * <li>{@link KeepItemKind#CLASS_AND_METHODS} if method patterns are defined;
- * <li>{@link KeepItemKind#CLASS_AND_FIELDS} if field patterns are defined;
- * <li>{@link KeepItemKind#CLASS_AND_MEMBERS} otherwise.
- * </ul>
- *
- * <p>
- * When annotating a method the default kind is: {@link KeepItemKind#ONLY_METHODS}
- *
- * <p>
- * When annotating a field the default kind is: {@link KeepItemKind#ONLY_FIELDS}
- *
- * <p>
- * It is not possible to use {@link KeepItemKind#ONLY_CLASS} if annotating a member.
- *
- * @return The kind for this pattern.
- */
- val kind: KeepItemKind = KeepItemKind.DEFAULT,
-
- /**
- * Define the usage constraints of the target.
- *
- * <p>
- * The specified constraints must remain valid for the target.
- *
- * <p>
- * The default constraints depend on the kind of the target. For all targets the default
- * constraints include:
- * <ul>
- * <li>{@link KeepConstraint#LOOKUP}
- * <li>{@link KeepConstraint#NAME}
- * <li>{@link KeepConstraint#VISIBILITY_RELAX}
- * </ul>
- *
- * <p>
- * For classes the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#CLASS_INSTANTIATE}
- * </ul>
- *
- * <p>
- * For methods the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#METHOD_INVOKE}
- * </ul>
- *
- * <p>
- * For fields the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#FIELD_GET}
- * <li>{@link KeepConstraint#FIELD_SET}
- * </ul>
- *
- * <p>
- * Mutually exclusive with the property `constraintAdditions` also defining constraints.
- *
- * @return Usage constraints for the target.
- */
- val constraints: Array<KeepConstraint> = [],
-
- /**
- * Add additional usage constraints of the target.
- *
- * <p>
- * The specified constraints must remain valid for the target in addition to the default
- * constraints.
- *
- * <p>
- * The default constraints are documented in {@link #constraints}
- *
- * <p>
- * Mutually exclusive with the property `constraints` also defining constraints.
- *
- * @return Additional usage constraints for the target.
- */
- val constraintAdditions: Array<KeepConstraint> = [],
-
- /**
- * Patterns for annotations that must remain on the item.
- *
- * <p>
- * The annotations matching any of the patterns must remain on the item if the annotation types
- * remain in the program.
- *
- * <p>
- * Note that if the annotation types themselves are unused/removed, then their references on the
- * item will be removed too. If the annotation types themselves are used reflectively then they
- * too need a keep annotation or rule to ensure they remain in the program.
- *
- * <p>
- * By default no annotation patterns are defined and no annotations are required to remain.
- *
- * @return Annotation patterns
- */
- val constrainAnnotations: Array<AnnotationPattern> = [],
-
- /**
- * Define the member-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassConstant
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val memberAnnotatedByClassName: String = "",
-
- /**
- * Define the member-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val memberAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the member-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val memberAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * @return The member access-flag constraints that must be met.
- */
- val memberAccess: Array<MemberAccessFlags> = [],
-
- /**
- * Define the method-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassConstant
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val methodAnnotatedByClassName: String = "",
-
- /**
- * Define the method-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val methodAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the method-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val methodAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the method-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any
- * method-access flags.
- *
- * @return The method access-flag constraints that must be met.
- */
- val methodAccess: Array<MethodAccessFlags> = [],
-
- /**
- * Define the method-name pattern by an exact method name.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodNamePattern` also defining method-name.
- *
- * @return The exact method name of the method.
- */
- val methodName: String = "",
-
- /**
- * Define the method-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodName` also defining method-name.
- *
- * @return The string pattern of the method name.
- */
- val methodNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the method return-type pattern by a fully qualified type or 'void'.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnTypeConstant
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return The qualified type name of the method return type.
- */
- val methodReturnType: String = "",
-
- /**
- * Define the method return-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return A class constant denoting the type of the method return type.
- */
- val methodReturnTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the method return-type pattern by a type pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypeConstant
- * </ul>
- *
- * @return The pattern of the method return type.
- */
- val methodReturnTypePattern: TypePattern = TypePattern(name = ""),
-
- /**
- * Define the method parameters pattern by a list of fully qualified types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
- *
- * @return The list of qualified type names of the method parameters.
- */
- val methodParameters: Array<String> = [""],
-
- /**
- * Define the method parameters pattern by a list of patterns on types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameters` also defining parameters.
- *
- * @return The list of type patterns for the method parameters.
- */
- val methodParameterTypePatterns: Array<TypePattern> = [TypePattern(name = "")],
-
- /**
- * Define the field-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassConstant
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val fieldAnnotatedByClassName: String = "",
-
- /**
- * Define the field-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val fieldAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val fieldAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the field-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field-access
- * flags.
- *
- * @return The field access-flag constraints that must be met.
- */
- val fieldAccess: Array<FieldAccessFlags> = [],
-
- /**
- * Define the field-name pattern by an exact field name.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldNamePattern` also defining field-name.
- *
- * @return The exact field name of the field.
- */
- val fieldName: String = "",
-
- /**
- * Define the field-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldName` also defining field-name.
- *
- * @return The string pattern of the field name.
- */
- val fieldNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the field-type pattern by a fully qualified type.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldTypeConstant
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The qualified type name for the field type.
- */
- val fieldType: String = "",
-
- /**
- * Define the field-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The class constant for the field type.
- */
- val fieldTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-type pattern by a pattern on types.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypeConstant
- * </ul>
- *
- * @return The type pattern for the field type.
- */
- val fieldTypePattern: TypePattern = TypePattern(name = ""),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/UsedByReflection.java b/src/keepanno/java/androidx/annotation/keep/UsedByReflection.java
new file mode 100644
index 0000000..7cf8b09
--- /dev/null
+++ b/src/keepanno/java/androidx/annotation/keep/UsedByReflection.java
@@ -0,0 +1,571 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ***********************************************************************************
+// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
+// ***********************************************************************************
+
+// ***********************************************************************************
+// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
+// ***********************************************************************************
+
+package androidx.annotation.keep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to mark a class, field or method as being accessed reflectively.
+ *
+ * <p>Note: Before using this annotation, consider if instead you can annotate the code that is
+ * doing reflection with {@link UsesReflection}. Annotating the reflecting code is generally more
+ * clear and maintainable, and it also naturally gives rise to edges that describe just the
+ * reflected aspects of the program. The {@link UsedByReflection} annotation is suitable for cases
+ * where the reflecting code is not under user control, or in migrating away from rules.
+ *
+ * <p>When a class is annotated, member patterns can be used to define which members are to be kept.
+ * When no member patterns are specified the default pattern is to match just the class.
+ *
+ * <p>When a member is annotated, the member patterns cannot be used as the annotated member itself
+ * fully defines the item to be kept (i.e., itself).
+ */
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface UsedByReflection {
+
+ /**
+ * Optional description to document the reason for this annotation.
+ *
+ * @return The descriptive message. Defaults to no description.
+ */
+ String description() default "";
+
+ /**
+ * Conditions that should be satisfied for the annotation to be in effect.
+ *
+ * @return The list of preconditions. Defaults to no conditions, thus trivially/unconditionally
+ * satisfied.
+ */
+ KeepCondition[] preconditions() default {};
+
+ /**
+ * Additional targets to be kept in addition to the annotated class/members.
+ *
+ * @return List of additional target consequences. Defaults to no additional target consequences.
+ */
+ KeepTarget[] additionalTargets() default {};
+
+ /**
+ * Specify the kind of this item pattern.
+ *
+ * <p>If unspecified the default kind depends on the annotated item.
+ *
+ * <p>When annotating a class the default kind is:
+ *
+ * <ul>
+ * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined;
+ * <li>{@link KeepItemKind#CLASS_AND_METHODS} if method patterns are defined;
+ * <li>{@link KeepItemKind#CLASS_AND_FIELDS} if field patterns are defined;
+ * <li>{@link KeepItemKind#CLASS_AND_MEMBERS} otherwise.
+ * </ul>
+ *
+ * <p>When annotating a method the default kind is: {@link KeepItemKind#ONLY_METHODS}
+ *
+ * <p>When annotating a field the default kind is: {@link KeepItemKind#ONLY_FIELDS}
+ *
+ * <p>It is not possible to use {@link KeepItemKind#ONLY_CLASS} if annotating a member.
+ *
+ * @return The kind for this pattern.
+ */
+ KeepItemKind kind() default KeepItemKind.DEFAULT;
+
+ /**
+ * Define the usage constraints of the target.
+ *
+ * <p>The specified constraints must remain valid for the target.
+ *
+ * <p>The default constraints depend on the kind of the target. For all targets the default
+ * constraints include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#LOOKUP}
+ * <li>{@link KeepConstraint#NAME}
+ * <li>{@link KeepConstraint#VISIBILITY_RELAX}
+ * </ul>
+ *
+ * <p>For classes the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#CLASS_INSTANTIATE}
+ * </ul>
+ *
+ * <p>For methods the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#METHOD_INVOKE}
+ * </ul>
+ *
+ * <p>For fields the default constraints also include:
+ *
+ * <ul>
+ * <li>{@link KeepConstraint#FIELD_GET}
+ * <li>{@link KeepConstraint#FIELD_SET}
+ * </ul>
+ *
+ * <p>Mutually exclusive with the property `constraintAdditions` also defining constraints.
+ *
+ * @return Usage constraints for the target.
+ */
+ KeepConstraint[] constraints() default {};
+
+ /**
+ * Add additional usage constraints of the target.
+ *
+ * <p>The specified constraints must remain valid for the target in addition to the default
+ * constraints.
+ *
+ * <p>The default constraints are documented in {@link #constraints}
+ *
+ * <p>Mutually exclusive with the property `constraints` also defining constraints.
+ *
+ * @return Additional usage constraints for the target.
+ */
+ KeepConstraint[] constraintAdditions() default {};
+
+ /**
+ * Patterns for annotations that must remain on the item.
+ *
+ * <p>The annotations matching any of the patterns must remain on the item if the annotation types
+ * remain in the program.
+ *
+ * <p>Note that if the annotation types themselves are unused/removed, then their references on
+ * the item will be removed too. If the annotation types themselves are used reflectively then
+ * they too need a keep annotation or rule to ensure they remain in the program.
+ *
+ * <p>By default no annotation patterns are defined and no annotations are required to remain.
+ *
+ * @return Annotation patterns
+ */
+ AnnotationPattern[] constrainAnnotations() default {};
+
+ /**
+ * Define the member-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassConstant
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String memberAnnotatedByClassName() default "";
+
+ /**
+ * Define the member-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> memberAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the member-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining member-annotated-by:
+ *
+ * <ul>
+ * <li>memberAnnotatedByClassName
+ * <li>memberAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * <p>If none are specified the default is to match any member regardless of what the member is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern memberAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the member-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field and method properties as use restricts the match to both
+ * types of members.
+ *
+ * @return The member access-flag constraints that must be met.
+ */
+ MemberAccessFlags[] memberAccess() default {};
+
+ /**
+ * Define the method-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassConstant
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String methodAnnotatedByClassName() default "";
+
+ /**
+ * Define the method-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> methodAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the method-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining method-annotated-by:
+ *
+ * <ul>
+ * <li>methodAnnotatedByClassName
+ * <li>methodAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none are specified the default is to match any method regardless of what the method is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern methodAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the method-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * method-access flags.
+ *
+ * @return The method access-flag constraints that must be met.
+ */
+ MethodAccessFlags[] methodAccess() default {};
+
+ /**
+ * Define the method-name pattern by an exact method name.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodNamePattern` also defining method-name.
+ *
+ * @return The exact method name of the method.
+ */
+ String methodName() default "";
+
+ /**
+ * Define the method-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any method
+ * name.
+ *
+ * <p>Mutually exclusive with the property `methodName` also defining method-name.
+ *
+ * @return The string pattern of the method name.
+ */
+ StringPattern methodNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the method return-type pattern by a fully qualified type or 'void'.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnTypeConstant
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return The qualified type name of the method return type.
+ */
+ String methodReturnType() default "";
+
+ /**
+ * Define the method return-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypePattern
+ * </ul>
+ *
+ * @return A class constant denoting the type of the method return type.
+ */
+ Class<?> methodReturnTypeConstant() default Object.class;
+
+ /**
+ * Define the method return-type pattern by a type pattern.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any return
+ * type.
+ *
+ * <p>Mutually exclusive with the following other properties defining return-type:
+ *
+ * <ul>
+ * <li>methodReturnType
+ * <li>methodReturnTypeConstant
+ * </ul>
+ *
+ * @return The pattern of the method return type.
+ */
+ TypePattern methodReturnTypePattern() default @TypePattern(name = "");
+
+ /**
+ * Define the method parameters pattern by a list of fully qualified types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
+ *
+ * @return The list of qualified type names of the method parameters.
+ */
+ String[] methodParameters() default {""};
+
+ /**
+ * Define the method parameters pattern by a list of patterns on types.
+ *
+ * <p>Mutually exclusive with all field properties.
+ *
+ * <p>If none, and other properties define this item as a method, the default matches any
+ * parameters.
+ *
+ * <p>Mutually exclusive with the property `methodParameters` also defining parameters.
+ *
+ * @return The list of type patterns for the method parameters.
+ */
+ TypePattern[] methodParameterTypePatterns() default {@TypePattern(name = "")};
+
+ /**
+ * Define the field-annotated-by pattern by fully qualified class name.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassConstant
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The qualified class name that defines the annotation.
+ */
+ String fieldAnnotatedByClassName() default "";
+
+ /**
+ * Define the field-annotated-by pattern by reference to a Class constant.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassNamePattern
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-constant that defines the annotation.
+ */
+ Class<?> fieldAnnotatedByClassConstant() default Object.class;
+
+ /**
+ * Define the field-annotated-by pattern by reference to a class-name pattern.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-annotated-by:
+ *
+ * <ul>
+ * <li>fieldAnnotatedByClassName
+ * <li>fieldAnnotatedByClassConstant
+ * </ul>
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none are specified the default is to match any field regardless of what the field is
+ * annotated by.
+ *
+ * @return The class-name pattern that defines the annotation.
+ */
+ ClassNamePattern fieldAnnotatedByClassNamePattern() default
+ @ClassNamePattern(unqualifiedName = "");
+
+ /**
+ * Define the field-access pattern by matching on access flags.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any
+ * field-access flags.
+ *
+ * @return The field access-flag constraints that must be met.
+ */
+ FieldAccessFlags[] fieldAccess() default {};
+
+ /**
+ * Define the field-name pattern by an exact field name.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldNamePattern` also defining field-name.
+ *
+ * @return The exact field name of the field.
+ */
+ String fieldName() default "";
+
+ /**
+ * Define the field-name pattern by a string pattern.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any field
+ * name.
+ *
+ * <p>Mutually exclusive with the property `fieldName` also defining field-name.
+ *
+ * @return The string pattern of the field name.
+ */
+ StringPattern fieldNamePattern() default @StringPattern(exact = "");
+
+ /**
+ * Define the field-type pattern by a fully qualified type.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldTypeConstant
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The qualified type name for the field type.
+ */
+ String fieldType() default "";
+
+ /**
+ * Define the field-type pattern by a class constant.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypePattern
+ * </ul>
+ *
+ * @return The class constant for the field type.
+ */
+ Class<?> fieldTypeConstant() default Object.class;
+
+ /**
+ * Define the field-type pattern by a pattern on types.
+ *
+ * <p>Mutually exclusive with all method properties.
+ *
+ * <p>If none, and other properties define this item as a field, the default matches any type.
+ *
+ * <p>Mutually exclusive with the following other properties defining field-type:
+ *
+ * <ul>
+ * <li>fieldType
+ * <li>fieldTypeConstant
+ * </ul>
+ *
+ * @return The type pattern for the field type.
+ */
+ TypePattern fieldTypePattern() default @TypePattern(name = "");
+}
diff --git a/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt b/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt
deleted file mode 100644
index 7c9f85f..0000000
--- a/src/keepanno/java/androidx/annotation/keep/UsedByReflection.kt
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ***********************************************************************************
-// GENERATED FILE. DO NOT EDIT! See KeepItemAnnotationGenerator.java.
-// ***********************************************************************************
-
-// ***********************************************************************************
-// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
-// ***********************************************************************************
-
-package androidx.annotation.keep
-
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
-import kotlin.reflect.KClass
-
-/**
- * Annotation to mark a class, field or method as being accessed reflectively.
- *
- * <p>
- * Note: Before using this annotation, consider if instead you can annotate the code that is doing
- * reflection with {@link UsesReflection}. Annotating the reflecting code is generally more clear
- * and maintainable, and it also naturally gives rise to edges that describe just the reflected
- * aspects of the program. The {@link UsedByReflection} annotation is suitable for cases where the
- * reflecting code is not under user control, or in migrating away from rules.
- *
- * <p>
- * When a class is annotated, member patterns can be used to define which members are to be kept.
- * When no member patterns are specified the default pattern is to match just the class.
- *
- * <p>
- * When a member is annotated, the member patterns cannot be used as the annotated member itself
- * fully defines the item to be kept (i.e., itself).
- */
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.CLASS,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class UsedByReflection(
-
- /**
- * Optional description to document the reason for this annotation.
- *
- * @return The descriptive message. Defaults to no description.
- */
- val description: String = "",
-
- /**
- * Conditions that should be satisfied for the annotation to be in effect.
- *
- * @return The list of preconditions. Defaults to no conditions, thus trivially/unconditionally
- * satisfied.
- */
- val preconditions: Array<KeepCondition> = [],
-
- /**
- * Additional targets to be kept in addition to the annotated class/members.
- *
- * @return List of additional target consequences. Defaults to no additional target consequences.
- */
- val additionalTargets: Array<KeepTarget> = [],
-
- /**
- * Specify the kind of this item pattern.
- *
- * <p>
- * If unspecified the default kind depends on the annotated item.
- *
- * <p>
- * When annotating a class the default kind is:
- * <ul>
- * <li>{@link KeepItemKind#ONLY_CLASS} if no member patterns are defined;
- * <li>{@link KeepItemKind#CLASS_AND_METHODS} if method patterns are defined;
- * <li>{@link KeepItemKind#CLASS_AND_FIELDS} if field patterns are defined;
- * <li>{@link KeepItemKind#CLASS_AND_MEMBERS} otherwise.
- * </ul>
- *
- * <p>
- * When annotating a method the default kind is: {@link KeepItemKind#ONLY_METHODS}
- *
- * <p>
- * When annotating a field the default kind is: {@link KeepItemKind#ONLY_FIELDS}
- *
- * <p>
- * It is not possible to use {@link KeepItemKind#ONLY_CLASS} if annotating a member.
- *
- * @return The kind for this pattern.
- */
- val kind: KeepItemKind = KeepItemKind.DEFAULT,
-
- /**
- * Define the usage constraints of the target.
- *
- * <p>
- * The specified constraints must remain valid for the target.
- *
- * <p>
- * The default constraints depend on the kind of the target. For all targets the default
- * constraints include:
- * <ul>
- * <li>{@link KeepConstraint#LOOKUP}
- * <li>{@link KeepConstraint#NAME}
- * <li>{@link KeepConstraint#VISIBILITY_RELAX}
- * </ul>
- *
- * <p>
- * For classes the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#CLASS_INSTANTIATE}
- * </ul>
- *
- * <p>
- * For methods the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#METHOD_INVOKE}
- * </ul>
- *
- * <p>
- * For fields the default constraints also include:
- * <ul>
- * <li>{@link KeepConstraint#FIELD_GET}
- * <li>{@link KeepConstraint#FIELD_SET}
- * </ul>
- *
- * <p>
- * Mutually exclusive with the property `constraintAdditions` also defining constraints.
- *
- * @return Usage constraints for the target.
- */
- val constraints: Array<KeepConstraint> = [],
-
- /**
- * Add additional usage constraints of the target.
- *
- * <p>
- * The specified constraints must remain valid for the target in addition to the default
- * constraints.
- *
- * <p>
- * The default constraints are documented in {@link #constraints}
- *
- * <p>
- * Mutually exclusive with the property `constraints` also defining constraints.
- *
- * @return Additional usage constraints for the target.
- */
- val constraintAdditions: Array<KeepConstraint> = [],
-
- /**
- * Patterns for annotations that must remain on the item.
- *
- * <p>
- * The annotations matching any of the patterns must remain on the item if the annotation types
- * remain in the program.
- *
- * <p>
- * Note that if the annotation types themselves are unused/removed, then their references on the
- * item will be removed too. If the annotation types themselves are used reflectively then they
- * too need a keep annotation or rule to ensure they remain in the program.
- *
- * <p>
- * By default no annotation patterns are defined and no annotations are required to remain.
- *
- * @return Annotation patterns
- */
- val constrainAnnotations: Array<AnnotationPattern> = [],
-
- /**
- * Define the member-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassConstant
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val memberAnnotatedByClassName: String = "",
-
- /**
- * Define the member-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val memberAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the member-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining member-annotated-by:
- * <ul>
- * <li>memberAnnotatedByClassName
- * <li>memberAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * <p>
- * If none are specified the default is to match any member regardless of what the member is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val memberAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the member-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field and method properties as use restricts the match to both
- * types of members.
- *
- * @return The member access-flag constraints that must be met.
- */
- val memberAccess: Array<MemberAccessFlags> = [],
-
- /**
- * Define the method-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassConstant
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val methodAnnotatedByClassName: String = "",
-
- /**
- * Define the method-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val methodAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the method-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining method-annotated-by:
- * <ul>
- * <li>methodAnnotatedByClassName
- * <li>methodAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none are specified the default is to match any method regardless of what the method is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val methodAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the method-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any
- * method-access flags.
- *
- * @return The method access-flag constraints that must be met.
- */
- val methodAccess: Array<MethodAccessFlags> = [],
-
- /**
- * Define the method-name pattern by an exact method name.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodNamePattern` also defining method-name.
- *
- * @return The exact method name of the method.
- */
- val methodName: String = "",
-
- /**
- * Define the method-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any method
- * name.
- *
- * <p>
- * Mutually exclusive with the property `methodName` also defining method-name.
- *
- * @return The string pattern of the method name.
- */
- val methodNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the method return-type pattern by a fully qualified type or 'void'.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnTypeConstant
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return The qualified type name of the method return type.
- */
- val methodReturnType: String = "",
-
- /**
- * Define the method return-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypePattern
- * </ul>
- *
- * @return A class constant denoting the type of the method return type.
- */
- val methodReturnTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the method return-type pattern by a type pattern.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any return
- * type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining return-type:
- * <ul>
- * <li>methodReturnType
- * <li>methodReturnTypeConstant
- * </ul>
- *
- * @return The pattern of the method return type.
- */
- val methodReturnTypePattern: TypePattern = TypePattern(name = ""),
-
- /**
- * Define the method parameters pattern by a list of fully qualified types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameterTypePatterns` also defining parameters.
- *
- * @return The list of qualified type names of the method parameters.
- */
- val methodParameters: Array<String> = [""],
-
- /**
- * Define the method parameters pattern by a list of patterns on types.
- *
- * <p>
- * Mutually exclusive with all field properties.
- *
- * <p>
- * If none, and other properties define this item as a method, the default matches any parameters.
- *
- * <p>
- * Mutually exclusive with the property `methodParameters` also defining parameters.
- *
- * @return The list of type patterns for the method parameters.
- */
- val methodParameterTypePatterns: Array<TypePattern> = [TypePattern(name = "")],
-
- /**
- * Define the field-annotated-by pattern by fully qualified class name.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassConstant
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The qualified class name that defines the annotation.
- */
- val fieldAnnotatedByClassName: String = "",
-
- /**
- * Define the field-annotated-by pattern by reference to a Class constant.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassNamePattern
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-constant that defines the annotation.
- */
- val fieldAnnotatedByClassConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-annotated-by pattern by reference to a class-name pattern.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-annotated-by:
- * <ul>
- * <li>fieldAnnotatedByClassName
- * <li>fieldAnnotatedByClassConstant
- * </ul>
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none are specified the default is to match any field regardless of what the field is
- * annotated by.
- *
- * @return The class-name pattern that defines the annotation.
- */
- val fieldAnnotatedByClassNamePattern: ClassNamePattern = ClassNamePattern(unqualifiedName = ""),
-
- /**
- * Define the field-access pattern by matching on access flags.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field-access
- * flags.
- *
- * @return The field access-flag constraints that must be met.
- */
- val fieldAccess: Array<FieldAccessFlags> = [],
-
- /**
- * Define the field-name pattern by an exact field name.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldNamePattern` also defining field-name.
- *
- * @return The exact field name of the field.
- */
- val fieldName: String = "",
-
- /**
- * Define the field-name pattern by a string pattern.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any field name.
- *
- * <p>
- * Mutually exclusive with the property `fieldName` also defining field-name.
- *
- * @return The string pattern of the field name.
- */
- val fieldNamePattern: StringPattern = StringPattern(exact = ""),
-
- /**
- * Define the field-type pattern by a fully qualified type.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldTypeConstant
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The qualified type name for the field type.
- */
- val fieldType: String = "",
-
- /**
- * Define the field-type pattern by a class constant.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypePattern
- * </ul>
- *
- * @return The class constant for the field type.
- */
- val fieldTypeConstant: KClass<*> = Object::class,
-
- /**
- * Define the field-type pattern by a pattern on types.
- *
- * <p>
- * Mutually exclusive with all method properties.
- *
- * <p>
- * If none, and other properties define this item as a field, the default matches any type.
- *
- * <p>
- * Mutually exclusive with the following other properties defining field-type:
- * <ul>
- * <li>fieldType
- * <li>fieldTypeConstant
- * </ul>
- *
- * @return The type pattern for the field type.
- */
- val fieldTypePattern: TypePattern = TypePattern(name = ""),
-)
diff --git a/src/keepanno/java/androidx/annotation/keep/UsesReflection.kt b/src/keepanno/java/androidx/annotation/keep/UsesReflection.java
similarity index 75%
rename from src/keepanno/java/androidx/annotation/keep/UsesReflection.kt
rename to src/keepanno/java/androidx/annotation/keep/UsesReflection.java
index ced4530..0d7ca88 100644
--- a/src/keepanno/java/androidx/annotation/keep/UsesReflection.kt
+++ b/src/keepanno/java/androidx/annotation/keep/UsesReflection.java
@@ -22,29 +22,29 @@
// MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
// ***********************************************************************************
-package androidx.annotation.keep
+package androidx.annotation.keep;
-import kotlin.annotation.Retention
-import kotlin.annotation.Target
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* Annotation to declare the reflective usages made by a class, method or field.
*
- * <p>
- * The annotation's 'value' is a list of targets to be kept if the annotated item is used. The
+ * <p>The annotation's 'value' is a list of targets to be kept if the annotated item is used. The
* annotated item is a precondition for keeping any of the specified targets. Thus, if an annotated
* method is determined to be unused by the program, the annotation itself will not be in effect and
* the targets will not be kept (assuming nothing else is otherwise keeping them).
*
- * <p>
- * The annotation's 'additionalPreconditions' is optional and can specify additional conditions that
- * should be satisfied for the annotation to be in effect.
+ * <p>The annotation's 'additionalPreconditions' is optional and can specify additional conditions
+ * that should be satisfied for the annotation to be in effect.
*
- * <p>
- * The translation of the {@link UsesReflection} annotation into a {@link KeepEdge} is as follows:
+ * <p>The translation of the {@link UsesReflection} annotation into a {@link KeepEdge} is as
+ * follows:
*
- * <p>
- * Assume the item of the annotation is denoted by 'CTX' and referred to as its context.
+ * <p>Assume the item of the annotation is denoted by 'CTX' and referred to as its context.
+ *
* <pre>
* @UsesReflection(value = targets, [additionalPreconditions = preconditions])
* ==>
@@ -75,33 +75,28 @@
* }
* </pre>
*/
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.CLASS,
- AnnotationTarget.FIELD,
- AnnotationTarget.FUNCTION,
- AnnotationTarget.CONSTRUCTOR,
-)
-annotation class UsesReflection(
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface UsesReflection {
/**
* Optional description to document the reason for this annotation.
*
* @return The descriptive message. Defaults to no description.
*/
- val description: String = "",
+ String description() default "";
/**
* Consequences that must be kept if the annotation is in effect.
*
* @return The list of target consequences.
*/
- val value: Array<KeepTarget>,
+ KeepTarget[] value();
/**
* Additional preconditions for the annotation to be in effect.
*
* @return The list of additional preconditions. Defaults to no additional preconditions.
*/
- val additionalPreconditions: Array<KeepCondition> = [],
-)
+ KeepCondition[] additionalPreconditions() default {};
+}
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..a84a54e 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
@@ -152,47 +152,13 @@
if (isDeprecated()) {
generator.println("@Deprecated");
}
- if (generator.generateKotlin()) {
- if (kotlinValueDefault() == null) {
- generator.println("val " + name + ": " + kotlinValueType() + ",");
- } else {
- generator.println(
- "val " + name + ": " + kotlinValueType() + " = " + kotlinValueDefault() + ",");
- }
+ if (valueDefault == null) {
+ generator.println(valueType + " " + name + "();");
} else {
- if (valueDefault == null) {
- generator.println(valueType + " " + name + "();");
- } else {
- generator.println(valueType + " " + name + "() default " + valueDefault + ";");
- }
+ generator.println(valueType + " " + name + "() default " + valueDefault + ";");
}
}
- private String kotlinValueType() {
- if (valueType.equals("Class<?>")) {
- return "KClass<*>";
- }
- if (valueType.equals("boolean")) {
- return "Boolean";
- }
- if (valueType.endsWith("[]")) {
- return "Array<" + valueType.substring(0, valueType.length() - 2) + ">";
- }
- return valueType;
- }
-
- private String kotlinValueDefault() {
- if (valueDefault != null) {
- if (valueDefault.equals("Object.class")) {
- return "Object::class";
- }
- if (valueDefault.startsWith("{") && valueDefault.endsWith("}")) {
- return "[" + valueDefault.substring(1, valueDefault.length() - 1) + "]";
- }
- }
- return valueDefault;
- }
-
public void generateConstants(Generator generator) {
generator.println("public static final String " + name + " = " + quote(name) + ";");
}
@@ -402,19 +368,13 @@
final EnumReference FIELD_ACCESS_TRANSIENT;
final List<EnumReference> FIELD_ACCESS_VALUES;
- final String KOTLIN_DEFAULT_INVALID_STRING_PATTERN;
final String DEFAULT_INVALID_STRING_PATTERN;
- final String KOTLIN_DEFAULT_INVALID_TYPE_PATTERN;
final String DEFAULT_INVALID_TYPE_PATTERN;
- final String KOTLIN_DEFAULT_INVALID_CLASS_NAME_PATTERN;
final String DEFAULT_INVALID_CLASS_NAME_PATTERN;
- final String KOTLIN_DEFAULT_ANY_INSTANCE_OF_PATTERN;
final String DEFAULT_ANY_INSTANCE_OF_PATTERN;
final List<Class<?>> ANNOTATION_IMPORTS =
ImmutableList.of(ElementType.class, Retention.class, RetentionPolicy.class, Target.class);
- final List<Class<?>> KOTLIN_ANNOTATION_IMPORTS =
- ImmutableList.of(kotlin.annotation.Retention.class, kotlin.annotation.Target.class);
private final PrintStream writer;
private final String pkg;
@@ -529,15 +489,10 @@
FIELD_ACCESS_TRANSIENT = enumRef(FIELD_ACCESS_FLAGS, "TRANSIENT");
FIELD_ACCESS_VALUES = ImmutableList.of(FIELD_ACCESS_VOLATILE, FIELD_ACCESS_TRANSIENT);
- KOTLIN_DEFAULT_INVALID_STRING_PATTERN = getUnqualifiedName(STRING_PATTERN) + "(exact = \"\")";
DEFAULT_INVALID_STRING_PATTERN = "@" + getUnqualifiedName(STRING_PATTERN) + "(exact = \"\")";
- KOTLIN_DEFAULT_INVALID_TYPE_PATTERN = getUnqualifiedName(TYPE_PATTERN) + "(name = \"\")";
DEFAULT_INVALID_TYPE_PATTERN = "@" + getUnqualifiedName(TYPE_PATTERN) + "(name = \"\")";
- KOTLIN_DEFAULT_INVALID_CLASS_NAME_PATTERN =
- getUnqualifiedName(CLASS_NAME_PATTERN) + "(unqualifiedName = \"\")";
DEFAULT_INVALID_CLASS_NAME_PATTERN =
"@" + getUnqualifiedName(CLASS_NAME_PATTERN) + "(unqualifiedName = \"\")";
- KOTLIN_DEFAULT_ANY_INSTANCE_OF_PATTERN = getUnqualifiedName(INSTANCE_OF_PATTERN) + "()";
DEFAULT_ANY_INSTANCE_OF_PATTERN = "@" + getUnqualifiedName(INSTANCE_OF_PATTERN) + "()";
}
@@ -556,10 +511,6 @@
indent -= 2;
}
- private boolean generateKotlin() {
- return pkg.startsWith("androidx.");
- }
-
private void println() {
println("");
}
@@ -588,7 +539,7 @@
}
private void printPackage() {
- println("package " + this.pkg + (generateKotlin() ? "" : ";"));
+ println("package " + this.pkg + ";");
println();
}
@@ -598,67 +549,9 @@
private void printImports(List<Class<?>> imports) {
for (Class<?> clazz : imports) {
- println("import " + clazz.getCanonicalName() + (generateKotlin() ? "" : ";"));
+ println("import " + clazz.getCanonicalName() + ";");
}
- }
-
- private void printAnnotationImports() {
- printImports(generateKotlin() ? KOTLIN_ANNOTATION_IMPORTS : ANNOTATION_IMPORTS);
- }
-
- private void printOpenAnnotationClassTargettingAnnotations(String clazz) {
- if (generateKotlin()) {
- println("@Retention(AnnotationRetention.BINARY)");
- println("@Target(AnnotationTarget.ANNOTATION_CLASS)");
- println("annotation class " + clazz + "(");
- } else {
- println("@Target(ElementType.ANNOTATION_TYPE)");
- println("@Retention(RetentionPolicy.CLASS)");
- println("public @interface " + clazz + " {");
- }
- }
-
- private void printOpenAnnotationClassTargettingClassFieldlMethodCtor(String clazz) {
- if (generateKotlin()) {
- println("@Retention(AnnotationRetention.BINARY)");
- println("@Target(");
- println(" AnnotationTarget.CLASS,");
- println(" AnnotationTarget.FIELD,");
- println(" AnnotationTarget.FUNCTION,");
- println(" AnnotationTarget.CONSTRUCTOR,");
- println(")");
- println("annotation class " + clazz + "(");
- } else {
- println(
- "@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,"
- + " ElementType.CONSTRUCTOR})");
- println("@Retention(RetentionPolicy.CLASS)");
- println("public @interface " + clazz + " {");
- }
- }
-
- private void printOpenAnnotationClassTargettingAnnotations(ClassReference clazz) {
- printOpenAnnotationClassTargettingAnnotations(getUnqualifiedName(clazz));
- }
-
- private String defaultInvalidClassNamePattern() {
- return generateKotlin()
- ? KOTLIN_DEFAULT_INVALID_CLASS_NAME_PATTERN
- : DEFAULT_INVALID_CLASS_NAME_PATTERN;
- }
-
- private String defaultInvalidStringPattern() {
- return generateKotlin()
- ? KOTLIN_DEFAULT_INVALID_STRING_PATTERN
- : DEFAULT_INVALID_STRING_PATTERN;
- }
-
- private String defaultInvalidTypePattern() {
- return generateKotlin() ? KOTLIN_DEFAULT_INVALID_TYPE_PATTERN : DEFAULT_INVALID_TYPE_PATTERN;
- }
-
- private void printCloseAnnotationClass() {
- println(generateKotlin() ? ")" : "}");
+ println();
}
private static String KIND_GROUP = "kind";
@@ -785,7 +678,7 @@
.addMember(
new GroupMember("classNamePattern")
.setDocTitle("Classes matching the class-name pattern.")
- .defaultValue(CLASS_NAME_PATTERN, defaultInvalidClassNamePattern()))
+ .defaultValue(CLASS_NAME_PATTERN, DEFAULT_INVALID_CLASS_NAME_PATTERN))
.addMember(instanceOfPattern());
// TODO(b/248408342): Add more injections on type pattern variants.
// /** Exact type name as a string to match any array with that type as member. */
@@ -823,7 +716,7 @@
.addMember(
new GroupMember("classNamePattern")
.setDocTitle("Instances of classes matching the class-name pattern.")
- .defaultValue(CLASS_NAME_PATTERN, defaultInvalidClassNamePattern()));
+ .defaultValue(CLASS_NAME_PATTERN, DEFAULT_INVALID_CLASS_NAME_PATTERN));
}
private Group classNamePatternFullNameGroup() {
@@ -862,7 +755,7 @@
.setDocTitle("Define the unqualified class-name pattern by a string pattern.")
.setDocReturn("The string pattern of the unqualified class name.")
.addParagraph("The default matches any unqualified name.")
- .defaultValue(STRING_PATTERN, defaultInvalidStringPattern()));
+ .defaultValue(STRING_PATTERN, DEFAULT_INVALID_STRING_PATTERN));
}
private Group classNamePatternPackageGroup() {
@@ -997,7 +890,7 @@
+ ANNOTATION_NAME_GROUP
+ " pattern by reference to a class-name pattern.")
.setDocReturn("The class-name pattern that defines the annotation.")
- .defaultValue(CLASS_NAME_PATTERN, defaultInvalidClassNamePattern());
+ .defaultValue(CLASS_NAME_PATTERN, DEFAULT_INVALID_CLASS_NAME_PATTERN);
}
private static GroupMember annotationRetention() {
@@ -1051,7 +944,7 @@
.setDocTitle(
"Define the " + CLASS_NAME_GROUP + " pattern by reference to a class-name pattern.")
.setDocReturn("The class-name pattern that defines the class.")
- .defaultValue(CLASS_NAME_PATTERN, defaultInvalidClassNamePattern());
+ .defaultValue(CLASS_NAME_PATTERN, DEFAULT_INVALID_CLASS_NAME_PATTERN);
}
private Group createClassNamePatternGroup() {
@@ -1114,11 +1007,7 @@
return new GroupMember("instanceOfPattern")
.setDocTitle("Define the " + INSTANCE_OF_GROUP + " with a pattern.")
.setDocReturn("The pattern that defines what instance-of the class must be.")
- .defaultValue(
- INSTANCE_OF_PATTERN,
- generateKotlin()
- ? KOTLIN_DEFAULT_ANY_INSTANCE_OF_PATTERN
- : DEFAULT_ANY_INSTANCE_OF_PATTERN);
+ .defaultValue(INSTANCE_OF_PATTERN, DEFAULT_ANY_INSTANCE_OF_PATTERN);
}
private Group createClassInstanceOfPatternGroup() {
@@ -1159,7 +1048,7 @@
.setDocTitle(
"Define the " + groupName + " pattern by reference to a class-name pattern.")
.setDocReturn("The class-name pattern that defines the annotation.")
- .defaultValue(CLASS_NAME_PATTERN, defaultInvalidClassNamePattern()));
+ .defaultValue(CLASS_NAME_PATTERN, DEFAULT_INVALID_CLASS_NAME_PATTERN));
}
private Group createClassAnnotatedByPatternGroup() {
@@ -1257,7 +1146,7 @@
.addParagraph(getMutuallyExclusiveForMethodProperties())
.addParagraph(getMethodDefaultDoc("any method name"))
.setDocReturn("The string pattern of the method name.")
- .defaultValue(STRING_PATTERN, defaultInvalidStringPattern()));
+ .defaultValue(STRING_PATTERN, DEFAULT_INVALID_STRING_PATTERN));
}
private Group createMethodReturnTypeGroup() {
@@ -1283,7 +1172,7 @@
.addParagraph(getMutuallyExclusiveForMethodProperties())
.addParagraph(getMethodDefaultDoc("any return type"))
.setDocReturn("The pattern of the method return type.")
- .defaultValue(TYPE_PATTERN, defaultInvalidTypePattern()));
+ .defaultValue(TYPE_PATTERN, DEFAULT_INVALID_TYPE_PATTERN));
}
private Group createMethodParametersGroup() {
@@ -1303,7 +1192,7 @@
.addParagraph(getMutuallyExclusiveForMethodProperties())
.addParagraph(getMethodDefaultDoc("any parameters"))
.setDocReturn("The list of type patterns for the method parameters.")
- .defaultArrayValue(TYPE_PATTERN, defaultInvalidTypePattern()));
+ .defaultArrayValue(TYPE_PATTERN, DEFAULT_INVALID_TYPE_PATTERN));
}
private Group createFieldAnnotatedByGroup() {
@@ -1339,7 +1228,7 @@
.addParagraph(getMutuallyExclusiveForFieldProperties())
.addParagraph(getFieldDefaultDoc("any field name"))
.setDocReturn("The string pattern of the field name.")
- .defaultValue(STRING_PATTERN, defaultInvalidStringPattern()));
+ .defaultValue(STRING_PATTERN, DEFAULT_INVALID_STRING_PATTERN));
}
private Group createFieldTypeGroup() {
@@ -1364,7 +1253,7 @@
.addParagraph(getMutuallyExclusiveForFieldProperties())
.addParagraph(getFieldDefaultDoc("any type"))
.setDocReturn("The type pattern for the field type.")
- .defaultValue(TYPE_PATTERN, defaultInvalidTypePattern()));
+ .defaultValue(TYPE_PATTERN, DEFAULT_INVALID_TYPE_PATTERN));
}
private void generateClassAndMemberPropertiesWithClassAndMemberBinding() {
@@ -1450,12 +1339,14 @@
private void generateStringPattern() {
printCopyRight(2024);
printPackage();
- printAnnotationImports();
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A pattern structure for matching strings.")
.addParagraph("If no properties are set, the default pattern matches any string.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations(STRING_PATTERN);
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + getUnqualifiedName(STRING_PATTERN) + " {");
println();
withIndent(
() -> {
@@ -1469,41 +1360,41 @@
println();
suffixGroup.generate(this);
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateTypePattern() {
printCopyRight(2023);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A pattern structure for matching types.")
.addParagraph("If no properties are set, the default pattern matches any type.")
.addParagraph("All properties on this annotation are mutually exclusive.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations(TYPE_PATTERN);
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + getUnqualifiedName(TYPE_PATTERN) + " {");
println();
withIndent(() -> typePatternGroup().generate(this));
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateClassNamePattern() {
printCopyRight(2023);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A pattern structure for matching names of classes and interfaces.")
.addParagraph(
"If no properties are set, the default pattern matches any name of a class or"
+ " interface.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations(CLASS_NAME_PATTERN);
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + getUnqualifiedName(CLASS_NAME_PATTERN) + " {");
println();
withIndent(
() -> {
@@ -1518,18 +1409,21 @@
println();
packageGroup.generate(this);
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateInstanceOfPattern() {
printCopyRight(2024);
printPackage();
- printAnnotationImports();
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A pattern structure for matching instances of classes and interfaces.")
.addParagraph("If no properties are set, the default pattern matches any instance.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations(INSTANCE_OF_PATTERN);
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + getUnqualifiedName(INSTANCE_OF_PATTERN) + " {");
println();
withIndent(
() -> {
@@ -1537,24 +1431,23 @@
println();
instanceOfPatternClassNamePattern().generate(this);
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateAnnotationPattern() {
printCopyRight(2024);
printPackage();
- printImports(RetentionPolicy.class);
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A pattern structure for matching annotations.")
.addParagraph(
"If no properties are set, the default pattern matches any annotation",
"with a runtime retention policy.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations(ANNOTATION_PATTERN);
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + getUnqualifiedName(ANNOTATION_PATTERN) + " {");
println();
withIndent(
() -> {
@@ -1562,16 +1455,14 @@
println();
annotationRetention().generate(this);
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateKeepBinding() {
printCopyRight(2022);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A binding of a keep item.")
.addParagraph(
@@ -1582,7 +1473,9 @@
.addUnorderedList(
"a pattern on classes;", "a pattern on methods; or", "a pattern on fields.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations("KeepBinding");
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface KeepBinding {");
println();
withIndent(
() -> {
@@ -1592,16 +1485,14 @@
println();
generateClassAndMemberPropertiesWithClassBinding();
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateKeepTarget() {
printCopyRight(2022);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A target for a keep edge.")
.addParagraph(
@@ -1609,7 +1500,9 @@
.addUnorderedList(
"a pattern on classes;", "a pattern on methods; or", "a pattern on fields.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations("KeepTarget");
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface KeepTarget {");
println();
withIndent(
() -> {
@@ -1622,16 +1515,14 @@
});
generateClassAndMemberPropertiesWithClassAndMemberBinding();
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateKeepCondition() {
printCopyRight(2022);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("A condition for a keep edge.")
.addParagraph(
@@ -1639,22 +1530,22 @@
.addUnorderedList(
"a pattern on classes;", "a pattern on methods; or", "a pattern on fields.")
.printDoc(this::println);
- printOpenAnnotationClassTargettingAnnotations("KeepCondition");
+ println("@Target(ElementType.ANNOTATION_TYPE)");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface KeepCondition {");
println();
withIndent(
() -> {
generateClassAndMemberPropertiesWithClassAndMemberBinding();
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateKeepForApi() {
printCopyRight(2023);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle(
"Annotation to mark a class, field or method as part of a library API surface.")
@@ -1666,7 +1557,11 @@
"When a member is annotated, the member patterns cannot be used as the annotated"
+ " member itself fully defines the item to be kept (i.e., itself).")
.printDoc(this::println);
- printOpenAnnotationClassTargettingClassFieldlMethodCtor("KeepForApi");
+ println(
+ "@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,"
+ + " ElementType.CONSTRUCTOR})");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface KeepForApi {");
println();
withIndent(
() -> {
@@ -1697,13 +1592,14 @@
println();
generateMemberPropertiesNoBinding();
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private void generateUsesReflection() {
printCopyRight(2022);
printPackage();
- printAnnotationImports();
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle(
"Annotation to declare the reflective usages made by a class, method or field.")
@@ -1755,7 +1651,11 @@
" // unreachable",
" }")
.printDoc(this::println);
- printOpenAnnotationClassTargettingClassFieldlMethodCtor(getUnqualifiedName(USES_REFLECTION));
+ println(
+ "@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,"
+ + " ElementType.CONSTRUCTOR})");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + getUnqualifiedName(USES_REFLECTION) + " {");
println();
withIndent(
() -> {
@@ -1765,16 +1665,13 @@
println();
createAdditionalPreconditionsGroup().generate(this);
});
- printCloseAnnotationClass();
+ println("}");
}
private void generateUsedByX(String annotationClassName, String doc) {
printCopyRight(2023);
printPackage();
- printAnnotationImports();
- if (generateKotlin()) {
- println("import kotlin.reflect.KClass");
- }
+ printImports(ANNOTATION_IMPORTS);
DocPrinter.printer()
.setDocTitle("Annotation to mark a class, field or method as being " + doc + ".")
.addParagraph(
@@ -1797,7 +1694,11 @@
"When a member is annotated, the member patterns cannot be used as the annotated"
+ " member itself fully defines the item to be kept (i.e., itself).")
.printDoc(this::println);
- printOpenAnnotationClassTargettingClassFieldlMethodCtor(annotationClassName);
+ println(
+ "@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,"
+ + " ElementType.CONSTRUCTOR})");
+ println("@Retention(RetentionPolicy.CLASS)");
+ println("public @interface " + annotationClassName + " {");
println();
withIndent(
() -> {
@@ -1837,7 +1738,8 @@
});
generateMemberPropertiesNoBinding();
});
- printCloseAnnotationClass();
+ println();
+ println("}");
}
private static String annoUnqualifiedName(ClassReference clazz) {
@@ -2288,7 +2190,56 @@
println();
}
- private static void copyNonGeneratedMethods() throws IOException {
+ private static void writeFile(Path file, Consumer<Generator> fn, BiConsumer<Path, String> write)
+ throws IOException {
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ PrintStream printStream = new PrintStream(byteStream);
+ Generator generator = new Generator(printStream, R8_ANNO_PKG);
+ fn.accept(generator);
+ String formatted = byteStream.toString();
+ if (file.toString().endsWith(".java")) {
+ formatted = CodeGenerationBase.javaFormatRawOutput(formatted);
+ }
+ Path resolved = Paths.get(ToolHelper.getProjectRoot()).resolve(file);
+ write.accept(resolved, formatted);
+ }
+
+ private static void writeFile(
+ String pkg,
+ Function<Generator, ClassReference> f,
+ Consumer<Generator> fn,
+ BiConsumer<Path, String> write)
+ throws IOException {
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ PrintStream printStream = new PrintStream(byteStream);
+ Generator generator = new Generator(printStream, pkg);
+ fn.accept(generator);
+ String formatted = byteStream.toString();
+ Path file = source(f.apply(generator));
+ if (file.toString().endsWith(".java")) {
+ formatted = CodeGenerationBase.javaFormatRawOutput(formatted);
+ }
+ Path resolved = Paths.get(ToolHelper.getProjectRoot()).resolve(file);
+ write.accept(resolved, formatted);
+ }
+
+ public static Path source(ClassReference clazz) {
+ return Paths.get("src", "keepanno", "java").resolve(clazz.getBinaryName() + ".java");
+ }
+
+ public static void run(BiConsumer<Path, String> write) throws IOException {
+ Path projectRoot = Paths.get(ToolHelper.getProjectRoot());
+ writeFile(
+ Paths.get("doc/keepanno-guide.md"),
+ generator -> KeepAnnoMarkdownGenerator.generateMarkdownDoc(generator, projectRoot),
+ write);
+
+ writeFile(
+ ANDROIDX_ANNO_PKG,
+ generator -> generator.ANNOTATION_CONSTANTS,
+ Generator::generateConstants,
+ write);
+ // Create a copy of the non-generated classes in the androidx namespace.
String[] nonGeneratedClasses =
new String[] {
"CheckOptimizedOut",
@@ -2319,70 +2270,6 @@
.collect(Collectors.toList()));
FileUtils.writeTextFile(toResolved, out);
}
- }
-
- private static void writeFile(Path file, Consumer<Generator> fn, BiConsumer<Path, String> write)
- throws IOException {
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- PrintStream printStream = new PrintStream(byteStream);
- Generator generator = new Generator(printStream, R8_ANNO_PKG);
- fn.accept(generator);
- String formatted = byteStream.toString();
- if (file.toString().endsWith(".kt")) {
- formatted = CodeGenerationBase.kotlinFormatRawOutput(formatted);
- } else if (file.toString().endsWith(".java")) {
- formatted = CodeGenerationBase.javaFormatRawOutput(formatted);
- }
- Path resolved = Paths.get(ToolHelper.getProjectRoot()).resolve(file);
- write.accept(resolved, formatted);
- }
-
- private static void writeFile(
- String pkg,
- Function<Generator, ClassReference> f,
- Consumer<Generator> fn,
- BiConsumer<Path, String> write)
- throws IOException {
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- PrintStream printStream = new PrintStream(byteStream);
- Generator generator = new Generator(printStream, pkg);
- fn.accept(generator);
- String formatted = byteStream.toString();
- Path file = source(f.apply(generator));
- if (file.toString().endsWith(".kt")) {
- formatted = CodeGenerationBase.kotlinFormatRawOutput(formatted);
- } else if (file.toString().endsWith(".java")) {
- formatted = CodeGenerationBase.javaFormatRawOutput(formatted);
- }
- Path resolved = Paths.get(ToolHelper.getProjectRoot()).resolve(file);
- write.accept(resolved, formatted);
- }
-
- public static Path source(ClassReference clazz) {
- Path keepAnnoSourcePath = Paths.get("src", "keepanno", "java");
- if (clazz.getBinaryName().startsWith("androidx/")) {
- return keepAnnoSourcePath.resolve(clazz.getBinaryName() + ".kt");
- } else {
- return keepAnnoSourcePath.resolve(clazz.getBinaryName() + ".java");
- }
- }
-
- public static void run(BiConsumer<Path, String> write) throws IOException {
- Path projectRoot = Paths.get(ToolHelper.getProjectRoot());
- writeFile(
- Paths.get("doc/keepanno-guide.md"),
- generator -> KeepAnnoMarkdownGenerator.generateMarkdownDoc(generator, projectRoot),
- write);
-
- writeFile(
- ANDROIDX_ANNO_PKG,
- generator -> generator.ANNOTATION_CONSTANTS,
- Generator::generateConstants,
- write);
- // Create a copy of the non-generated classes in the androidx namespace.
- // This is currently disabled. Will potentially be re-introduced by converting these classes
- // to Kotlin in the R8 keep anno namespace.
- // copyNonGeneratedMethods();
for (String pkg : new String[] {R8_ANNO_PKG, ANDROIDX_ANNO_PKG}) {
writeFile(
pkg, generator -> generator.STRING_PATTERN, Generator::generateStringPattern, write);