[KeepAnno] Remove interpretation of "default" values.
If reader does not see default properties as it only identifies
properties that are explicitly defined.
Bug: b/248408342
Change-Id: I148fbe861798aa2577333652985d669df805bf51
diff --git a/src/keepanno/java/com/android/tools/r8/keepanno/asm/KeepEdgeReader.java b/src/keepanno/java/com/android/tools/r8/keepanno/asm/KeepEdgeReader.java
index ed65592..fb229fb 100644
--- a/src/keepanno/java/com/android/tools/r8/keepanno/asm/KeepEdgeReader.java
+++ b/src/keepanno/java/com/android/tools/r8/keepanno/asm/KeepEdgeReader.java
@@ -54,7 +54,6 @@
import com.android.tools.r8.keepanno.ast.KeepTypePattern;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -746,9 +745,6 @@
super.visitEnum(name, descriptor, value);
}
switch (value) {
- case Kind.DEFAULT:
- // The default value is obtained by not assigning a kind (e.g., null in the builder).
- break;
case Kind.ONLY_CLASS:
case Kind.ONLY_MEMBERS:
case Kind.CLASS_AND_MEMBERS:
@@ -1333,18 +1329,12 @@
@Override
boolean tryParse(String name, Object value) {
if (name.equals(Item.methodName) && value instanceof String) {
- String methodName = (String) value;
- if (!Item.methodNameDefaultValue.equals(methodName)) {
- getBuilder().setNamePattern(KeepMethodNamePattern.exact(methodName));
- }
+ getBuilder().setNamePattern(KeepMethodNamePattern.exact((String) value));
return true;
}
if (name.equals(Item.methodReturnType) && value instanceof String) {
- String returnType = (String) value;
- if (!Item.methodReturnTypeDefaultValue.equals(returnType)) {
- getBuilder()
- .setReturnTypePattern(KeepEdgeReaderUtils.methodReturnTypeFromString(returnType));
- }
+ getBuilder()
+ .setReturnTypePattern(KeepEdgeReaderUtils.methodReturnTypeFromString((String) value));
return true;
}
return false;
@@ -1360,9 +1350,6 @@
return new StringArrayVisitor(
annotationName,
params -> {
- if (Arrays.asList(Item.methodParametersDefaultValue).equals(params)) {
- return;
- }
KeepMethodParametersPattern.Builder builder = KeepMethodParametersPattern.builder();
for (String param : params) {
builder.addParameterTypePattern(KeepEdgeReaderUtils.typePatternFromString(param));
@@ -1412,20 +1399,14 @@
@Override
boolean tryParse(String name, Object value) {
if (name.equals(Item.fieldName) && value instanceof String) {
- String fieldName = (String) value;
- if (!Item.fieldNameDefaultValue.equals(fieldName)) {
- getBuilder().setNamePattern(KeepFieldNamePattern.exact(fieldName));
- }
+ getBuilder().setNamePattern(KeepFieldNamePattern.exact((String) value));
return true;
}
if (name.equals(Item.fieldType) && value instanceof String) {
- String fieldType = (String) value;
- if (!Item.fieldTypeDefaultValue.equals(fieldType)) {
- getBuilder()
- .setTypePattern(
- KeepFieldTypePattern.fromType(
- KeepEdgeReaderUtils.typePatternFromString(fieldType)));
- }
+ getBuilder()
+ .setTypePattern(
+ KeepFieldTypePattern.fromType(
+ KeepEdgeReaderUtils.typePatternFromString((String) value)));
return true;
}
return false;
@@ -1610,9 +1591,6 @@
super.visitEnum(name, descriptor, value);
}
switch (value) {
- case Kind.DEFAULT:
- // The default value is obtained by not assigning a kind (e.g., null in the builder).
- break;
case Kind.ONLY_CLASS:
case Kind.ONLY_MEMBERS:
case Kind.CLASS_AND_MEMBERS:
diff --git a/src/keepanno/java/com/android/tools/r8/keepanno/ast/AnnotationConstants.java b/src/keepanno/java/com/android/tools/r8/keepanno/ast/AnnotationConstants.java
index abea1c1..09ef4cf 100644
--- a/src/keepanno/java/com/android/tools/r8/keepanno/ast/AnnotationConstants.java
+++ b/src/keepanno/java/com/android/tools/r8/keepanno/ast/AnnotationConstants.java
@@ -130,24 +130,6 @@
public static final String fieldAccess = "fieldAccess";
public static final String fieldName = "fieldName";
public static final String fieldType = "fieldType";
-
- // Default values for the optional entries. The defaults should be chosen such that they do
- // not coincide with any actual valid value. E.g., the empty string in place of a name or type.
- // These must be 1:1 with the value defined on the actual annotation definition.
- public static final String classNameDefault = "";
- public static final Class<?> classConstantDefault = Object.class;
-
- public static final String extendsClassNameDefault = "";
- public static final Class<?> extendsClassConstantDefault = Object.class;
-
- public static final String methodNameDefaultValue = "";
- public static final String methodReturnTypeDefaultValue = "";
-
- @SuppressWarnings("MutablePublicArray")
- public static final String[] methodParametersDefaultValue = new String[] {""};
-
- public static final String fieldNameDefaultValue = "";
- public static final String fieldTypeDefaultValue = "";
}
public static final class Binding {
@@ -174,7 +156,6 @@
public static final Class<KeepItemKind> CLASS = KeepItemKind.class;
public static final String DESCRIPTOR = getDescriptor(CLASS);
- public static final String DEFAULT = "DEFAULT";
public static final String ONLY_CLASS = "ONLY_CLASS";
public static final String ONLY_MEMBERS = "ONLY_MEMBERS";
public static final String CLASS_AND_MEMBERS = "CLASS_AND_MEMBERS";