Report origin of keep rule files that retain invisible annotations
This is only enabled when the system property com.android.tools.r8.enableKeepRuntimeInvisibleAnnotations is set to false.
Bug: b/387958004
Change-Id: I93491d41e3eba9ab5304552733f153dde7d045b4
diff --git a/src/main/java/com/android/tools/r8/shaking/ProguardConfigurationParser.java b/src/main/java/com/android/tools/r8/shaking/ProguardConfigurationParser.java
index bacebd7..78cec87 100644
--- a/src/main/java/com/android/tools/r8/shaking/ProguardConfigurationParser.java
+++ b/src/main/java/com/android/tools/r8/shaking/ProguardConfigurationParser.java
@@ -277,7 +277,8 @@
// Collect the parsed configuration.
configurationBuilder.addParsedConfiguration(contents.substring(positionAfterInclude));
- configurationBuilder.addParsedConfiguration("# End of content from " + origin.toString());
+ configurationBuilder.addParsedConfiguration("# End of content from " + origin);
+ reporter.failIfPendingErrors();
}
private boolean parseOption() throws ProguardRuleParserException {
@@ -763,6 +764,19 @@
if (attributesPatterns.isEmpty()) {
throw parseError("Expected attribute pattern list");
}
+ if (!options.isKeepRuntimeInvisibleAnnotationsEnabled()) {
+ ProguardKeepAttributes keepAttributes =
+ ProguardKeepAttributes.fromPatterns(attributesPatterns);
+ if (keepAttributes.runtimeInvisibleAnnotations
+ || keepAttributes.runtimeInvisibleParameterAnnotations
+ || keepAttributes.runtimeInvisibleTypeAnnotations) {
+ reporter.error(
+ new StringDiagnostic(
+ "Illegal attempt to keep runtime invisible annotations (origin: "
+ + origin
+ + ")"));
+ }
+ }
configurationBuilder.addKeepAttributePatterns(attributesPatterns);
}