Remove use of JDK11 flag
Bug: b:231287675
Change-Id: Ic8de19ab966decd93bbc912829e2ab195f0c2816
diff --git a/src/test/java/com/android/tools/r8/MarkersTest.java b/src/test/java/com/android/tools/r8/MarkersTest.java
index 758b061..7ebe85b 100644
--- a/src/test/java/com/android/tools/r8/MarkersTest.java
+++ b/src/test/java/com/android/tools/r8/MarkersTest.java
@@ -14,12 +14,15 @@
import static com.android.tools.r8.MarkerMatcher.markerMinApi;
import static com.android.tools.r8.MarkerMatcher.markerR8Mode;
import static com.android.tools.r8.MarkerMatcher.markerTool;
+import static com.android.tools.r8.desugar.desugaredlibrary.test.CompilationSpecification.DEFAULT_SPECIFICATIONS;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.desugar.desugaredlibrary.DesugaredLibraryTestBase;
+import com.android.tools.r8.desugar.desugaredlibrary.test.CompilationSpecification;
+import com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification;
import com.android.tools.r8.dex.Marker;
import com.android.tools.r8.dex.Marker.Tool;
import com.android.tools.r8.origin.Origin;
@@ -41,27 +44,27 @@
public class MarkersTest extends DesugaredLibraryTestBase {
@Parameterized.Parameters(
- name = "{0}, compilationMode {1}, shrinkDesugaredLibrary {2}, noCfMarkerForDesugaredCode {3}")
+ name = "{0}, spec: {1}, compilationMode {2}, {3}, noCfMarkerForDesugaredCode {4}")
public static Collection<Object[]> data() {
return buildParameters(
getTestParameters().withNoneRuntime().build(),
- CompilationMode.values(),
- BooleanUtils.values(),
+ LibraryDesugaringSpecification.getJdk8Jdk11(),
+ DEFAULT_SPECIFICATIONS,
BooleanUtils.values());
}
- private final CompilationMode compilationMode;
- private final boolean shrinkDesugaredLibrary;
+ private final LibraryDesugaringSpecification libraryDesugaringSpecification;
+ private final CompilationSpecification compilationSpecification;
private final boolean noCfMarkerForDesugaredCode;
public MarkersTest(
TestParameters parameters,
- CompilationMode compilationMode,
- boolean shrinkDesugaredLibrary,
+ LibraryDesugaringSpecification libraryDesugaringSpecification,
+ CompilationSpecification compilationSpecification,
boolean noCfMarkerForDesugaredCode) {
parameters.assertNoneRuntime();
- this.compilationMode = compilationMode;
- this.shrinkDesugaredLibrary = shrinkDesugaredLibrary;
+ this.libraryDesugaringSpecification = libraryDesugaringSpecification;
+ this.compilationSpecification = compilationSpecification;
this.noCfMarkerForDesugaredCode = noCfMarkerForDesugaredCode;
}
@@ -72,17 +75,18 @@
AndroidApiLevel apiLevel = AndroidApiLevel.L;
Path output = temp.newFolder().toPath().resolve("desugar_jdk_libs.zip");
+ CompilationMode compilationMode =
+ compilationSpecification.isL8Shrink() ? CompilationMode.RELEASE : CompilationMode.DEBUG;
L8Command.Builder builder =
L8Command.builder()
- .addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
- .addProgramFiles(ToolHelper.getDesugarJDKLibs())
- .addProgramFiles(ToolHelper.DESUGAR_LIB_CONVERSIONS)
+ .addLibraryFiles(libraryDesugaringSpecification.getLibraryFiles())
+ .addProgramFiles(libraryDesugaringSpecification.getDesugarJdkLibs())
.setMinApiLevel(apiLevel.getLevel())
.setMode(compilationMode)
.addDesugaredLibraryConfiguration(
- StringResource.fromFile(ToolHelper.getDesugarLibJsonForTesting()))
+ StringResource.fromFile(libraryDesugaringSpecification.getSpecification()))
.setOutput(output, OutputMode.DexIndexed);
- if (shrinkDesugaredLibrary) {
+ if (compilationSpecification.isL8Shrink()) {
builder.addProguardConfiguration(ImmutableList.of("-keep class * { *; }"), Origin.unknown());
}
L8.run(builder.build());
@@ -111,7 +115,8 @@
Matcher<Marker> d8Matcher =
allOf(markerTool(Tool.D8), markerCompilationMode(compilationMode), markerMinApi(apiLevel));
assertMarkersMatch(
- markers, ImmutableList.of(l8Matcher, shrinkDesugaredLibrary ? r8Matcher : d8Matcher));
+ markers,
+ ImmutableList.of(l8Matcher, compilationSpecification.isL8Shrink() ? r8Matcher : d8Matcher));
}
@Test
@@ -122,7 +127,7 @@
D8Command.builder()
.addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
.addProgramFiles(ToolHelper.getClassFileForTestClass(TestClass.class))
- .setMode(compilationMode)
+ .setMode(compilationSpecification.getProgramCompilationMode())
.setMinApiLevel(apiLevel.getLevel())
.setOutput(output, OutputMode.DexIndexed);
if (noCfMarkerForDesugaredCode) {
@@ -135,7 +140,7 @@
Matcher<Marker> matcher =
allOf(
markerTool(Tool.D8),
- markerCompilationMode(compilationMode),
+ markerCompilationMode(compilationSpecification.getProgramCompilationMode()),
markerBackend(Backend.DEX),
markerIsDesugared(),
markerMinApi(apiLevel),
@@ -146,7 +151,7 @@
@Test
public void testD8MarkerInCf() throws Throwable {
// Shrinking of desugared library is not affecting this test.
- assumeTrue(shrinkDesugaredLibrary);
+ assumeTrue(compilationSpecification.isL8Shrink());
AndroidApiLevel apiLevel = AndroidApiLevel.L;
Path output = temp.newFolder().toPath().resolve("output.zip");
@@ -154,7 +159,7 @@
D8Command.builder()
.addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
.addProgramFiles(ToolHelper.getClassFileForTestClass(TestClass.class))
- .setMode(compilationMode)
+ .setMode(compilationSpecification.getProgramCompilationMode())
.setMinApiLevel(apiLevel.getLevel())
.setOutput(output, OutputMode.ClassFile);
if (noCfMarkerForDesugaredCode) {
@@ -168,7 +173,7 @@
Matcher<Marker> matcher =
allOf(
markerTool(Tool.D8),
- markerCompilationMode(compilationMode),
+ markerCompilationMode(compilationSpecification.getProgramCompilationMode()),
markerBackend(Backend.CF),
markerIsDesugared(),
markerMinApi(apiLevel),
@@ -180,7 +185,7 @@
@Test
public void testR8MarkerInDex() throws Throwable {
// Shrinking of desugared library is not affecting this test.
- assumeTrue(shrinkDesugaredLibrary);
+ assumeTrue(compilationSpecification.isL8Shrink());
AndroidApiLevel apiLevel = AndroidApiLevel.L;
Path output = temp.newFolder().toPath().resolve("output.zip");
@@ -189,7 +194,7 @@
.addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
.addProgramFiles(ToolHelper.getClassFileForTestClass(TestClass.class))
.addProguardConfiguration(ImmutableList.of("-keep class * { *; }"), Origin.unknown())
- .setMode(compilationMode)
+ .setMode(compilationSpecification.getProgramCompilationMode())
.setMinApiLevel(apiLevel.getLevel())
.setOutput(output, OutputMode.DexIndexed);
if (noCfMarkerForDesugaredCode) {
@@ -203,7 +208,7 @@
Matcher<Marker> matcher =
allOf(
markerTool(Tool.R8),
- markerCompilationMode(compilationMode),
+ markerCompilationMode(compilationSpecification.getProgramCompilationMode()),
markerBackend(Backend.DEX),
markerIsDesugared(),
markerMinApi(apiLevel),
@@ -214,7 +219,7 @@
@Test
public void testR8MarkerInCf() throws Throwable {
// Shrinking of desugared library is not affecting this test.
- assumeTrue(shrinkDesugaredLibrary);
+ assumeTrue(compilationSpecification.isL8Shrink());
Path output = temp.newFolder().toPath().resolve("output.zip");
R8Command.Builder builder =
@@ -222,7 +227,7 @@
.addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
.addProgramFiles(ToolHelper.getClassFileForTestClass(TestClass.class))
.addProguardConfiguration(ImmutableList.of("-keep class * { *; }"), Origin.unknown())
- .setMode(compilationMode)
+ .setMode(compilationSpecification.getProgramCompilationMode())
.setOutput(output, OutputMode.ClassFile);
if (noCfMarkerForDesugaredCode) {
ToolHelper.runR8(
@@ -235,7 +240,7 @@
Matcher<Marker> matcher =
allOf(
markerTool(Tool.R8),
- markerCompilationMode(compilationMode),
+ markerCompilationMode(compilationSpecification.getProgramCompilationMode()),
markerBackend(Backend.CF),
not(markerIsDesugared()),
not(markerHasMinApi()),
@@ -246,7 +251,7 @@
@Test
public void testR8MarkerInCfAfterD8CfDesugar() throws Throwable {
// Shrinking of desugared library is not affecting this test.
- assumeTrue(shrinkDesugaredLibrary);
+ assumeTrue(compilationSpecification.isL8Shrink());
AndroidApiLevel apiLevel = AndroidApiLevel.L;
Path d8DesugaredOutput = temp.newFolder().toPath().resolve("output.zip");
@@ -254,7 +259,7 @@
D8Command.builder()
.addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
.addProgramFiles(ToolHelper.getClassFileForTestClass(TestClass.class))
- .setMode(compilationMode)
+ .setMode(compilationSpecification.getProgramCompilationMode())
.setMinApiLevel(apiLevel.getLevel())
.setOutput(d8DesugaredOutput, OutputMode.ClassFile);
if (noCfMarkerForDesugaredCode) {
@@ -268,7 +273,7 @@
ExtractMarker.extractMarkerFromDexFile(d8DesugaredOutput),
allOf(
markerTool(Tool.D8),
- markerCompilationMode(compilationMode),
+ markerCompilationMode(compilationSpecification.getProgramCompilationMode()),
markerIsDesugared(),
markerMinApi(apiLevel),
not(markerHasDesugaredLibraryIdentifier())));
@@ -281,14 +286,14 @@
.addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.P))
.addProgramFiles(ToolHelper.getClassFileForTestClass(TestClass.class))
.addProguardConfiguration(ImmutableList.of("-keep class * { *; }"), Origin.unknown())
- .setMode(compilationMode)
+ .setMode(compilationSpecification.getProgramCompilationMode())
.setOutput(output, OutputMode.ClassFile)
.build());
assertMarkersMatch(
ExtractMarker.extractMarkerFromDexFile(output),
allOf(
markerTool(Tool.R8),
- markerCompilationMode(compilationMode),
+ markerCompilationMode(compilationSpecification.getProgramCompilationMode()),
markerBackend(Backend.CF),
not(markerIsDesugared()),
not(markerHasMinApi()),
diff --git a/src/test/java/com/android/tools/r8/TestCompilerBuilder.java b/src/test/java/com/android/tools/r8/TestCompilerBuilder.java
index 8123b33..cc47c89 100644
--- a/src/test/java/com/android/tools/r8/TestCompilerBuilder.java
+++ b/src/test/java/com/android/tools/r8/TestCompilerBuilder.java
@@ -494,14 +494,6 @@
return allowStderrMessages();
}
- public T enableCoreLibraryDesugaring(
- AndroidApiLevel minApiLevel, KeepRuleConsumer keepRuleConsumer) {
- return enableCoreLibraryDesugaring(
- minApiLevel,
- keepRuleConsumer,
- StringResource.fromFile(ToolHelper.getDesugarLibJsonForTesting()));
- }
-
public T enableCoreLibraryDesugaring(LibraryDesugaringTestConfiguration configuration) {
this.libraryDesugaringTestConfiguration = configuration;
return self();
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/BackwardsCompatibleSpecificationTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/BackwardsCompatibleSpecificationTest.java
index 817268d..9fe7609 100644
--- a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/BackwardsCompatibleSpecificationTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/BackwardsCompatibleSpecificationTest.java
@@ -3,16 +3,18 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.desugar.desugaredlibrary;
+import static com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification.JDK8;
import static org.junit.Assert.assertEquals;
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.ToolHelper.ProcessResult;
+import com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification;
import com.google.common.collect.ImmutableList;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
-import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -24,15 +26,19 @@
@Parameterized.Parameters(name = "{1}")
public static List<Object[]> data() {
- return buildParameters(getTestParameters().withNoneRuntime().build(), RELEASES);
+ return buildParameters(
+ getTestParameters().withNoneRuntime().build(), ImmutableList.of(JDK8), RELEASES);
}
- private final Path desugaredLib = ToolHelper.getDesugarJDKLibs();
- private final Path desugaredSpec = ToolHelper.getDesugarLibJsonForTesting();
+ private final LibraryDesugaringSpecification libraryDesugaringSpecification;
private final String release;
- public BackwardsCompatibleSpecificationTest(TestParameters parameters, String release) {
+ public BackwardsCompatibleSpecificationTest(
+ TestParameters parameters,
+ LibraryDesugaringSpecification libraryDesugaringSpecification,
+ String release) {
parameters.assertNoneRuntime();
+ this.libraryDesugaringSpecification = libraryDesugaringSpecification;
this.release = release;
}
@@ -42,16 +48,14 @@
@Test
public void test() throws Exception {
- Assume.assumeFalse(
- "When using JDK11 desugared library, we're not backward compatible to 2.0.74.",
- isJDK11DesugaredLibrary());
- ProcessResult result =
- ToolHelper.runJava(
- getReleaseJar(),
- "com.android.tools.r8.L8",
- "--desugared-lib",
- desugaredSpec.toString(),
- desugaredLib.toString());
+ ArrayList<String> command = new ArrayList<>();
+ command.add("com.android.tools.r8.L8");
+ command.add("--desugared-lib");
+ command.add(libraryDesugaringSpecification.getSpecification().toString());
+ for (Path desugarJdkLib : libraryDesugaringSpecification.getDesugarJdkLibs()) {
+ command.add(desugarJdkLib.toString());
+ }
+ ProcessResult result = ToolHelper.runJava(getReleaseJar(), command.toArray(new String[0]));
assertEquals(result.toString(), 0, result.exitCode);
}
}