Annotation Type KeepTarget
-
@Target(ANNOTATION_TYPE) @Retention(CLASS) public @interface KeepTarget
A target for a keep edge.The target denotes an item along with options for what to keep. An item can be:
- a pattern on classes;
- a pattern on methods; or
- a pattern on fields.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>
classAnnotatedByClassConstant
Define the class-annotated-by pattern by reference to a Class constant.java.lang.String
classAnnotatedByClassName
Define the class-annotated-by pattern by fully qualified class name.ClassNamePattern
classAnnotatedByClassNamePattern
Define the class-annotated-by pattern by reference to a class-name pattern.java.lang.Class<?>
classConstant
Define the class-name pattern by reference to a Class constant.java.lang.String
classFromBinding
Define the class pattern by reference to a binding.java.lang.String
className
Define the class-name pattern by fully qualified class name.ClassNamePattern
classNamePattern
Define the class-name pattern by reference to a class-name pattern.AnnotationPattern[]
constrainAnnotations
Patterns for annotations that must remain on the item.KeepConstraint[]
constraintAdditions
Add additional usage constraints of the target.KeepConstraint[]
constraints
Define the usage constraints of the target.FieldAccessFlags[]
fieldAccess
Define the field-access pattern by matching on access flags.java.lang.Class<?>
fieldAnnotatedByClassConstant
Define the field-annotated-by pattern by reference to a Class constant.java.lang.String
fieldAnnotatedByClassName
Define the field-annotated-by pattern by fully qualified class name.ClassNamePattern
fieldAnnotatedByClassNamePattern
Define the field-annotated-by pattern by reference to a class-name pattern.java.lang.String
fieldName
Define the field-name pattern by an exact field name.StringPattern
fieldNamePattern
Define the field-name pattern by a string pattern.java.lang.String
fieldType
Define the field-type pattern by a fully qualified type.java.lang.Class<?>
fieldTypeConstant
Define the field-type pattern by a class constant.TypePattern
fieldTypePattern
Define the field-type pattern by a pattern on types.java.lang.Class<?>
instanceOfClassConstant
Define the instance-of pattern as classes that are instances the referenced Class constant.java.lang.Class<?>
instanceOfClassConstantExclusive
Define the instance-of pattern as classes that are instances the referenced Class constant.java.lang.String
instanceOfClassName
Define the instance-of pattern as classes that are instances of the fully qualified class name.java.lang.String
instanceOfClassNameExclusive
Define the instance-of pattern as classes that are instances of the fully qualified class name.InstanceOfPattern
instanceOfPattern
Define the instance-of with a pattern.KeepItemKind
kind
Specify the kind of this item pattern.MemberAccessFlags[]
memberAccess
Define the member-access pattern by matching on access flags.java.lang.Class<?>
memberAnnotatedByClassConstant
Define the member-annotated-by pattern by reference to a Class constant.java.lang.String
memberAnnotatedByClassName
Define the member-annotated-by pattern by fully qualified class name.ClassNamePattern
memberAnnotatedByClassNamePattern
Define the member-annotated-by pattern by reference to a class-name pattern.java.lang.String
memberFromBinding
Define the member pattern in full by a reference to a binding.MethodAccessFlags[]
methodAccess
Define the method-access pattern by matching on access flags.java.lang.Class<?>
methodAnnotatedByClassConstant
Define the method-annotated-by pattern by reference to a Class constant.java.lang.String
methodAnnotatedByClassName
Define the method-annotated-by pattern by fully qualified class name.ClassNamePattern
methodAnnotatedByClassNamePattern
Define the method-annotated-by pattern by reference to a class-name pattern.java.lang.String
methodName
Define the method-name pattern by an exact method name.StringPattern
methodNamePattern
Define the method-name pattern by a string pattern.java.lang.String[]
methodParameters
Define the method parameters pattern by a list of fully qualified types.TypePattern[]
methodParameterTypePatterns
Define the method parameters pattern by a list of patterns on types.java.lang.String
methodReturnType
Define the method return-type pattern by a fully qualified type or 'void'.java.lang.Class<?>
methodReturnTypeConstant
Define the method return-type pattern by a class constant.TypePattern
methodReturnTypePattern
Define the method return-type pattern by a type pattern.
-
-
-
Element Detail
-
kind
KeepItemKind kind
Specify the kind of this item pattern.Possible values are:
KeepItemKind.ONLY_CLASS
KeepItemKind.ONLY_MEMBERS
KeepItemKind.ONLY_METHODS
KeepItemKind.ONLY_FIELDS
KeepItemKind.CLASS_AND_MEMBERS
KeepItemKind.CLASS_AND_METHODS
KeepItemKind.CLASS_AND_FIELDS
If unspecified the default kind for an item depends on its member patterns:
KeepItemKind.ONLY_CLASS
if no member patterns are definedKeepItemKind.ONLY_METHODS
if method patterns are definedKeepItemKind.ONLY_FIELDS
if field patterns are definedKeepItemKind.ONLY_MEMBERS
otherwise.
- Returns:
- The kind for this pattern.
- Default:
- com.android.tools.r8.keepanno.annotations.KeepItemKind.DEFAULT
-
-
-
constraints
KeepConstraint[] constraints
Define the usage constraints of the target.The specified constraints must remain valid for the target.
The default constraints depend on the kind of the target. For all targets the default constraints include:
For classes the default constraints also include:
For methods the default constraints also include:
For fields the default constraints also include:
Mutually exclusive with the property `constraintAdditions` also defining constraints.
- Returns:
- Usage constraints for the target.
- Default:
- {}
-
-
-
constraintAdditions
KeepConstraint[] constraintAdditions
Add additional usage constraints of the target.The specified constraints must remain valid for the target in addition to the default constraints.
The default constraints are documented in
constraints()
Mutually exclusive with the property `constraints` also defining constraints.
- Returns:
- Additional usage constraints for the target.
- Default:
- {}
-
-
-
constrainAnnotations
AnnotationPattern[] constrainAnnotations
Patterns for annotations that must remain on the item.The annotations matching any of the patterns must remain on the item if the annotation types remain in the program.
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.
By default no annotation patterns are defined and no annotations are required to remain.
- Returns:
- Annotation patterns
- Default:
- {}
-
-
-
classFromBinding
java.lang.String classFromBinding
Define the class pattern by reference to a binding.Mutually exclusive with the following other properties defining class:
- className
- classConstant
- classNamePattern
- instanceOfClassName
- instanceOfClassNameExclusive
- instanceOfClassConstant
- instanceOfClassConstantExclusive
- instanceOfPattern
- classAnnotatedByClassName
- classAnnotatedByClassConstant
- classAnnotatedByClassNamePattern
If none are specified the default is to match any class.
- Returns:
- The name of the binding that defines the class.
- Default:
- ""
-
-
-
className
java.lang.String className
Define the class-name pattern by fully qualified class name.Mutually exclusive with the following other properties defining class-name:
- classConstant
- classNamePattern
- classFromBinding
If none are specified the default is to match any class name.
- Returns:
- The qualified class name that defines the class.
- Default:
- ""
-
-
-
classConstant
java.lang.Class<?> classConstant
Define the class-name pattern by reference to a Class constant.Mutually exclusive with the following other properties defining class-name:
- className
- classNamePattern
- classFromBinding
If none are specified the default is to match any class name.
- Returns:
- The class-constant that defines the class.
- Default:
- java.lang.Object.class
-
-
-
classNamePattern
ClassNamePattern classNamePattern
Define the class-name pattern by reference to a class-name pattern.Mutually exclusive with the following other properties defining class-name:
- className
- classConstant
- classFromBinding
If none are specified the default is to match any class name.
- Returns:
- The class-name pattern that defines the class.
- Default:
- @com.android.tools.r8.keepanno.annotations.ClassNamePattern(unqualifiedName="")
-
-
-
instanceOfClassName
java.lang.String instanceOfClassName
Define the instance-of pattern as classes that are instances of the fully qualified class name.Mutually exclusive with the following other properties defining instance-of:
- instanceOfClassNameExclusive
- instanceOfClassConstant
- instanceOfClassConstantExclusive
- instanceOfPattern
- classFromBinding
If none are specified the default is to match any class instance.
- Returns:
- The qualified class name that defines what instance-of the class must be.
- Default:
- ""
-
-
-
instanceOfClassNameExclusive
java.lang.String instanceOfClassNameExclusive
Define the instance-of pattern as classes that are instances of the fully qualified class name.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.
Mutually exclusive with the following other properties defining instance-of:
- instanceOfClassName
- instanceOfClassConstant
- instanceOfClassConstantExclusive
- instanceOfPattern
- classFromBinding
If none are specified the default is to match any class instance.
- Returns:
- The qualified class name that defines what instance-of the class must be.
- Default:
- ""
-
-
-
instanceOfClassConstant
java.lang.Class<?> instanceOfClassConstant
Define the instance-of pattern as classes that are instances the referenced Class constant.Mutually exclusive with the following other properties defining instance-of:
- instanceOfClassName
- instanceOfClassNameExclusive
- instanceOfClassConstantExclusive
- instanceOfPattern
- classFromBinding
If none are specified the default is to match any class instance.
- Returns:
- The class constant that defines what instance-of the class must be.
- Default:
- java.lang.Object.class
-
-
-
instanceOfClassConstantExclusive
java.lang.Class<?> instanceOfClassConstantExclusive
Define the instance-of pattern as classes that are instances the referenced Class constant.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.
Mutually exclusive with the following other properties defining instance-of:
- instanceOfClassName
- instanceOfClassNameExclusive
- instanceOfClassConstant
- instanceOfPattern
- classFromBinding
If none are specified the default is to match any class instance.
- Returns:
- The class constant that defines what instance-of the class must be.
- Default:
- java.lang.Object.class
-
-
-
instanceOfPattern
InstanceOfPattern instanceOfPattern
Define the instance-of with a pattern.Mutually exclusive with the following other properties defining instance-of:
- instanceOfClassName
- instanceOfClassNameExclusive
- instanceOfClassConstant
- instanceOfClassConstantExclusive
- classFromBinding
If none are specified the default is to match any class instance.
- Returns:
- The pattern that defines what instance-of the class must be.
- Default:
- @com.android.tools.r8.keepanno.annotations.InstanceOfPattern
-
-
-
classAnnotatedByClassName
java.lang.String classAnnotatedByClassName
Define the class-annotated-by pattern by fully qualified class name.Mutually exclusive with the following other properties defining class-annotated-by:
- classAnnotatedByClassConstant
- classAnnotatedByClassNamePattern
- classFromBinding
If none are specified the default is to match any class regardless of what the class is annotated by.
- Returns:
- The qualified class name that defines the annotation.
- Default:
- ""
-
-
-
classAnnotatedByClassConstant
java.lang.Class<?> classAnnotatedByClassConstant
Define the class-annotated-by pattern by reference to a Class constant.Mutually exclusive with the following other properties defining class-annotated-by:
- classAnnotatedByClassName
- classAnnotatedByClassNamePattern
- classFromBinding
If none are specified the default is to match any class regardless of what the class is annotated by.
- Returns:
- The class-constant that defines the annotation.
- Default:
- java.lang.Object.class
-
-
-
classAnnotatedByClassNamePattern
ClassNamePattern classAnnotatedByClassNamePattern
Define the class-annotated-by pattern by reference to a class-name pattern.Mutually exclusive with the following other properties defining class-annotated-by:
- classAnnotatedByClassName
- classAnnotatedByClassConstant
- classFromBinding
If none are specified the default is to match any class regardless of what the class is annotated by.
- Returns:
- The class-name pattern that defines the annotation.
- Default:
- @com.android.tools.r8.keepanno.annotations.ClassNamePattern(unqualifiedName="")
-
-
-
memberFromBinding
java.lang.String memberFromBinding
Define the member pattern in full by a reference to a binding.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.
- Returns:
- The binding name that defines the member.
- Default:
- ""
-
-
-
memberAnnotatedByClassName
java.lang.String memberAnnotatedByClassName
Define the member-annotated-by pattern by fully qualified class name.Mutually exclusive with the following other properties defining member-annotated-by:
- memberAnnotatedByClassConstant
- memberAnnotatedByClassNamePattern
- memberFromBinding
Mutually exclusive with all field and method properties as use restricts the match to both types of members.
If none are specified the default is to match any member regardless of what the member is annotated by.
- Returns:
- The qualified class name that defines the annotation.
- Default:
- ""
-
-
-
memberAnnotatedByClassConstant
java.lang.Class<?> memberAnnotatedByClassConstant
Define the member-annotated-by pattern by reference to a Class constant.Mutually exclusive with the following other properties defining member-annotated-by:
- memberAnnotatedByClassName
- memberAnnotatedByClassNamePattern
- memberFromBinding
Mutually exclusive with all field and method properties as use restricts the match to both types of members.
If none are specified the default is to match any member regardless of what the member is annotated by.
- Returns:
- The class-constant that defines the annotation.
- Default:
- java.lang.Object.class
-
-
-
memberAnnotatedByClassNamePattern
ClassNamePattern memberAnnotatedByClassNamePattern
Define the member-annotated-by pattern by reference to a class-name pattern.Mutually exclusive with the following other properties defining member-annotated-by:
- memberAnnotatedByClassName
- memberAnnotatedByClassConstant
- memberFromBinding
Mutually exclusive with all field and method properties as use restricts the match to both types of members.
If none are specified the default is to match any member regardless of what the member is annotated by.
- Returns:
- The class-name pattern that defines the annotation.
- Default:
- @com.android.tools.r8.keepanno.annotations.ClassNamePattern(unqualifiedName="")
-
-
-
memberAccess
MemberAccessFlags[] memberAccess
Define the member-access pattern by matching on access flags.Mutually exclusive with all field and method properties as use restricts the match to both types of members.
Mutually exclusive with the property `memberFromBinding` also defining member-access.
- Returns:
- The member access-flag constraints that must be met.
- Default:
- {}
-
-
-
methodAnnotatedByClassName
java.lang.String methodAnnotatedByClassName
Define the method-annotated-by pattern by fully qualified class name.Mutually exclusive with the following other properties defining method-annotated-by:
- methodAnnotatedByClassConstant
- methodAnnotatedByClassNamePattern
- memberFromBinding
Mutually exclusive with all field properties.
If none are specified the default is to match any method regardless of what the method is annotated by.
- Returns:
- The qualified class name that defines the annotation.
- Default:
- ""
-
-
-
methodAnnotatedByClassConstant
java.lang.Class<?> methodAnnotatedByClassConstant
Define the method-annotated-by pattern by reference to a Class constant.Mutually exclusive with the following other properties defining method-annotated-by:
- methodAnnotatedByClassName
- methodAnnotatedByClassNamePattern
- memberFromBinding
Mutually exclusive with all field properties.
If none are specified the default is to match any method regardless of what the method is annotated by.
- Returns:
- The class-constant that defines the annotation.
- Default:
- java.lang.Object.class
-
-
-
methodAnnotatedByClassNamePattern
ClassNamePattern methodAnnotatedByClassNamePattern
Define the method-annotated-by pattern by reference to a class-name pattern.Mutually exclusive with the following other properties defining method-annotated-by:
- methodAnnotatedByClassName
- methodAnnotatedByClassConstant
- memberFromBinding
Mutually exclusive with all field properties.
If none are specified the default is to match any method regardless of what the method is annotated by.
- Returns:
- The class-name pattern that defines the annotation.
- Default:
- @com.android.tools.r8.keepanno.annotations.ClassNamePattern(unqualifiedName="")
-
-
-
methodAccess
MethodAccessFlags[] methodAccess
Define the method-access pattern by matching on access flags.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any method-access flags.
Mutually exclusive with the property `memberFromBinding` also defining method-access.
- Returns:
- The method access-flag constraints that must be met.
- Default:
- {}
-
-
-
methodName
java.lang.String methodName
Define the method-name pattern by an exact method name.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any method name.
Mutually exclusive with the following other properties defining method-name:
- methodNamePattern
- memberFromBinding
- Returns:
- The exact method name of the method.
- Default:
- ""
-
-
-
methodNamePattern
StringPattern methodNamePattern
Define the method-name pattern by a string pattern.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any method name.
Mutually exclusive with the following other properties defining method-name:
- methodName
- memberFromBinding
- Returns:
- The string pattern of the method name.
- Default:
- @com.android.tools.r8.keepanno.annotations.StringPattern(exact="")
-
-
-
methodReturnType
java.lang.String methodReturnType
Define the method return-type pattern by a fully qualified type or 'void'.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any return type.
Mutually exclusive with the following other properties defining return-type:
- methodReturnTypeConstant
- methodReturnTypePattern
- memberFromBinding
- Returns:
- The qualified type name of the method return type.
- Default:
- ""
-
-
-
methodReturnTypeConstant
java.lang.Class<?> methodReturnTypeConstant
Define the method return-type pattern by a class constant.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any return type.
Mutually exclusive with the following other properties defining return-type:
- methodReturnType
- methodReturnTypePattern
- memberFromBinding
- Returns:
- A class constant denoting the type of the method return type.
- Default:
- java.lang.Object.class
-
-
-
methodReturnTypePattern
TypePattern methodReturnTypePattern
Define the method return-type pattern by a type pattern.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any return type.
Mutually exclusive with the following other properties defining return-type:
- methodReturnType
- methodReturnTypeConstant
- memberFromBinding
- Returns:
- The pattern of the method return type.
- Default:
- @com.android.tools.r8.keepanno.annotations.TypePattern(name="")
-
-
-
methodParameters
java.lang.String[] methodParameters
Define the method parameters pattern by a list of fully qualified types.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any parameters.
Mutually exclusive with the following other properties defining parameters:
- methodParameterTypePatterns
- memberFromBinding
- Returns:
- The list of qualified type names of the method parameters.
- Default:
- {""}
-
-
-
methodParameterTypePatterns
TypePattern[] methodParameterTypePatterns
Define the method parameters pattern by a list of patterns on types.Mutually exclusive with all field properties.
If none, and other properties define this item as a method, the default matches any parameters.
Mutually exclusive with the following other properties defining parameters:
- methodParameters
- memberFromBinding
- Returns:
- The list of type patterns for the method parameters.
- Default:
- {@com.android.tools.r8.keepanno.annotations.TypePattern(name="")}
-
-
-
fieldAnnotatedByClassName
java.lang.String fieldAnnotatedByClassName
Define the field-annotated-by pattern by fully qualified class name.Mutually exclusive with the following other properties defining field-annotated-by:
- fieldAnnotatedByClassConstant
- fieldAnnotatedByClassNamePattern
- memberFromBinding
Mutually exclusive with all method properties.
If none are specified the default is to match any field regardless of what the field is annotated by.
- Returns:
- The qualified class name that defines the annotation.
- Default:
- ""
-
-
-
fieldAnnotatedByClassConstant
java.lang.Class<?> fieldAnnotatedByClassConstant
Define the field-annotated-by pattern by reference to a Class constant.Mutually exclusive with the following other properties defining field-annotated-by:
- fieldAnnotatedByClassName
- fieldAnnotatedByClassNamePattern
- memberFromBinding
Mutually exclusive with all method properties.
If none are specified the default is to match any field regardless of what the field is annotated by.
- Returns:
- The class-constant that defines the annotation.
- Default:
- java.lang.Object.class
-
-
-
fieldAnnotatedByClassNamePattern
ClassNamePattern fieldAnnotatedByClassNamePattern
Define the field-annotated-by pattern by reference to a class-name pattern.Mutually exclusive with the following other properties defining field-annotated-by:
- fieldAnnotatedByClassName
- fieldAnnotatedByClassConstant
- memberFromBinding
Mutually exclusive with all method properties.
If none are specified the default is to match any field regardless of what the field is annotated by.
- Returns:
- The class-name pattern that defines the annotation.
- Default:
- @com.android.tools.r8.keepanno.annotations.ClassNamePattern(unqualifiedName="")
-
-
-
fieldAccess
FieldAccessFlags[] fieldAccess
Define the field-access pattern by matching on access flags.Mutually exclusive with all method properties.
If none, and other properties define this item as a field, the default matches any field-access flags.
Mutually exclusive with the property `memberFromBinding` also defining field-access.
- Returns:
- The field access-flag constraints that must be met.
- Default:
- {}
-
-
-
fieldName
java.lang.String fieldName
Define the field-name pattern by an exact field name.Mutually exclusive with all method properties.
If none, and other properties define this item as a field, the default matches any field name.
Mutually exclusive with the following other properties defining field-name:
- fieldNamePattern
- memberFromBinding
- Returns:
- The exact field name of the field.
- Default:
- ""
-
-
-
fieldNamePattern
StringPattern fieldNamePattern
Define the field-name pattern by a string pattern.Mutually exclusive with all method properties.
If none, and other properties define this item as a field, the default matches any field name.
Mutually exclusive with the following other properties defining field-name:
- fieldName
- memberFromBinding
- Returns:
- The string pattern of the field name.
- Default:
- @com.android.tools.r8.keepanno.annotations.StringPattern(exact="")
-
-
-
fieldType
java.lang.String fieldType
Define the field-type pattern by a fully qualified type.Mutually exclusive with all method properties.
If none, and other properties define this item as a field, the default matches any type.
Mutually exclusive with the following other properties defining field-type:
- fieldTypeConstant
- fieldTypePattern
- memberFromBinding
- Returns:
- The qualified type name for the field type.
- Default:
- ""
-
-
-
fieldTypeConstant
java.lang.Class<?> fieldTypeConstant
Define the field-type pattern by a class constant.Mutually exclusive with all method properties.
If none, and other properties define this item as a field, the default matches any type.
Mutually exclusive with the following other properties defining field-type:
- fieldType
- fieldTypePattern
- memberFromBinding
- Returns:
- The class constant for the field type.
- Default:
- java.lang.Object.class
-
-
-
fieldTypePattern
TypePattern fieldTypePattern
Define the field-type pattern by a pattern on types.Mutually exclusive with all method properties.
If none, and other properties define this item as a field, the default matches any type.
Mutually exclusive with the following other properties defining field-type:
- fieldType
- fieldTypeConstant
- memberFromBinding
- Returns:
- The type pattern for the field type.
- Default:
- @com.android.tools.r8.keepanno.annotations.TypePattern(name="")
-
-