Revert "Update marker API with access to more of the marker information"
This reverts commit 821e72a75f5761e8057e6cb1a73b5b620dfed7f2.
Reason for revert: test failures
Change-Id: I6900a3e464ed0f05c1542b002f389ca4bd2c09ad
diff --git a/src/main/java/com/android/tools/r8/MarkerInfo.java b/src/main/java/com/android/tools/r8/MarkerInfo.java
index 6c5925d..32578c1 100644
--- a/src/main/java/com/android/tools/r8/MarkerInfo.java
+++ b/src/main/java/com/android/tools/r8/MarkerInfo.java
@@ -10,9 +10,6 @@
/** Get the tool that has generated the marker. */
String getTool();
- /** Get the version of the tool that has generated the marker. */
- String getVersion();
-
/** True of the generating tool was the R8 compiler. */
boolean isR8();
@@ -25,30 +22,6 @@
/** Get the min-api specified by the marker, or -1 if not defined. */
int getMinApi();
- /** True if the "backend" information is present or can be inferred for the tool. */
- boolean hasBackend();
-
- /** True if the tool is known to be targeting class files as backend output. */
- boolean isBackendClassFiles();
-
- /** True if the tool is known to be targeting DEX as backend output. */
- boolean isBackendDexFiles();
-
- /** True if the tool has a known compilation mode (i.e., release or debug). */
- boolean hasCompilationMode();
-
- /** True if the tool has a known compilation mode and the mode is "debug". */
- boolean isCompilationModeDebug();
-
- /** True if the tool has a known compilation mode and the mode is "release". */
- boolean isCompilationModeRelease();
-
- /** True if the tool is R8 using compatibility mode. */
- boolean isR8ModeCompatibility();
-
- /** True if the tool is R8 using full mode (e.g., not in compatibility mode). */
- boolean isR8ModeFull();
-
/**
* Get the raw encoding of the marker used by the compilers.
*
diff --git a/src/main/java/com/android/tools/r8/dex/Marker.java b/src/main/java/com/android/tools/r8/dex/Marker.java
index 7562bd0..c507995 100644
--- a/src/main/java/com/android/tools/r8/dex/Marker.java
+++ b/src/main/java/com/android/tools/r8/dex/Marker.java
@@ -152,15 +152,8 @@
return this;
}
- public boolean hasCompilationMode() {
- return jsonObject.has(COMPILATION_MODE);
- }
-
public String getCompilationMode() {
- if (hasCompilationMode()) {
- return jsonObject.get(COMPILATION_MODE).getAsString();
- }
- return null;
+ return jsonObject.get(COMPILATION_MODE).getAsString();
}
public Marker setCompilationMode(CompilationMode mode) {
@@ -174,23 +167,13 @@
}
public String getBackend() {
- if (hasBackend()) {
- jsonObject.get(BACKEND).getAsString();
+ if (!hasBackend()) {
+ // Before adding backend we would always compile to dex if min-api was specified.
+ return hasMinApi()
+ ? StringUtils.toLowerCase(Backend.DEX.name())
+ : StringUtils.toLowerCase(Backend.CF.name());
}
- switch (tool) {
- case D8:
- case L8:
- case R8:
- // Before adding backend we would always compile to dex if min-api was specified.
- // This is not fully true for D8 which had a window from aug to oct 2020 where the min-api
- // was added for CF builds too. However, that was (and still is) only used internally and
- // those markers should be be found in the wild.
- return hasMinApi()
- ? StringUtils.toLowerCase(Backend.DEX.name())
- : StringUtils.toLowerCase(Backend.CF.name());
- default:
- return null;
- }
+ return jsonObject.get(BACKEND).getAsString();
}
public boolean isCfBackend() {
diff --git a/src/main/java/com/android/tools/r8/utils/MarkerInfoImpl.java b/src/main/java/com/android/tools/r8/utils/MarkerInfoImpl.java
index 5b6fe01..bcbbeeb 100644
--- a/src/main/java/com/android/tools/r8/utils/MarkerInfoImpl.java
+++ b/src/main/java/com/android/tools/r8/utils/MarkerInfoImpl.java
@@ -19,11 +19,6 @@
}
@Override
- public String getVersion() {
- return marker.getVersion();
- }
-
- @Override
public String getTool() {
return marker.getTool().toString();
}
@@ -49,46 +44,6 @@
}
@Override
- public boolean hasBackend() {
- return marker.getBackend() != null;
- }
-
- @Override
- public boolean isBackendClassFiles() {
- return "cf".equals(marker.getBackend());
- }
-
- @Override
- public boolean isBackendDexFiles() {
- return "dex".equals(marker.getBackend());
- }
-
- @Override
- public boolean hasCompilationMode() {
- return marker.hasCompilationMode();
- }
-
- @Override
- public boolean isCompilationModeDebug() {
- return "debug".equals(marker.getCompilationMode());
- }
-
- @Override
- public boolean isCompilationModeRelease() {
- return "release".equals(marker.getCompilationMode());
- }
-
- @Override
- public boolean isR8ModeCompatibility() {
- return isR8() && "compatibility".equals(marker.getR8Mode());
- }
-
- @Override
- public boolean isR8ModeFull() {
- return isR8() && "full".equals(marker.getR8Mode());
- }
-
- @Override
public String getRawEncoding() {
return marker.toString();
}
diff --git a/src/test/java/com/android/tools/r8/compilerapi/extractmarker/ExtractMarkerApiTest.java b/src/test/java/com/android/tools/r8/compilerapi/extractmarker/ExtractMarkerApiTest.java
index 489b6a7..20e2bd4 100644
--- a/src/test/java/com/android/tools/r8/compilerapi/extractmarker/ExtractMarkerApiTest.java
+++ b/src/test/java/com/android/tools/r8/compilerapi/extractmarker/ExtractMarkerApiTest.java
@@ -114,14 +114,6 @@
assertFalse(marker.isR8());
assertFalse(marker.isL8());
assertEquals(1, marker.getMinApi());
- assertTrue(marker.hasBackend());
- assertTrue(marker.isBackendDexFiles());
- assertFalse(marker.isBackendClassFiles());
- assertTrue(marker.hasCompilationMode());
- assertTrue(marker.isCompilationModeDebug());
- assertFalse(marker.isCompilationModeRelease());
- assertFalse(marker.isR8ModeCompatibility());
- assertFalse(marker.isR8ModeFull());
assertThat(marker.getRawEncoding(), startsWith("~~D8{"));
} else {
assertTrue(origin == originCf || origin.equals(new PathOrigin(inputFile)));