aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar kmb <kmb@google.com>2018-03-01 16:26:21 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-01 16:27:53 -0800
commitf090082d62c3ea779d2dd33eb0fd7355b0ee9456 (patch)
treed4c2fd6f2b3ac8708e5a8a66105cdd64e9f3f603 /src/test/java/com/google/devtools/build
parent99be8b417a95224f66b3e00c9103cbde460d3b07 (diff)
Android desugar config options to exclude methods from interface emulation
RELNOTES: None. PiperOrigin-RevId: 187551970
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java44
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java3
2 files changed, 45 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java b/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java
index 90350ce753..e6f34ba9d4 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java
+++ b/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java
@@ -37,6 +37,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of("java/time/"),
ImmutableList.of(),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(support.isRenamedCoreLibrary("java/time/X")).isTrue();
assertThat(support.isRenamedCoreLibrary("java/time/y/X")).isTrue();
@@ -55,6 +56,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of("java/time/"),
ImmutableList.of(),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(support.isRenamedCoreLibrary("__/java/time/X")).isTrue();
assertThat(support.isRenamedCoreLibrary("__/java/time/y/X")).isTrue();
@@ -63,6 +65,7 @@ public class CoreLibrarySupportTest {
assertThat(support.isRenamedCoreLibrary("__/java/io/X$$Lambda$17")).isTrue();
assertThat(support.isRenamedCoreLibrary("com/google/X")).isFalse();
}
+
@Test
public void testRenameCoreLibrary() throws Exception {
CoreLibrarySupport support =
@@ -72,6 +75,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of(),
ImmutableList.of(),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(support.renameCoreLibrary("java/time/X")).isEqualTo("j$/time/X");
assertThat(support.renameCoreLibrary("com/google/X")).isEqualTo("com/google/X");
@@ -86,6 +90,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of(),
ImmutableList.of(),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(support.renameCoreLibrary("__/java/time/X")).isEqualTo("j$/time/X");
assertThat(support.renameCoreLibrary("com/google/X")).isEqualTo("com/google/X");
@@ -100,7 +105,8 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of("java/util/Helper"),
ImmutableList.of(),
- ImmutableList.of("java/util/Existing#match -> java/util/Helper"));
+ ImmutableList.of("java/util/Existing#match -> java/util/Helper"),
+ ImmutableList.of());
assertThat(support.getMoveTarget("__/java/util/Existing", "match")).isEqualTo("j$/util/Helper");
assertThat(support.getMoveTarget("java/util/Existing", "match")).isEqualTo("j$/util/Helper");
assertThat(support.getMoveTarget("__/java/util/Existing", "matchesnot")).isNull();
@@ -116,6 +122,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of("java/util/concurrent/"),
ImmutableList.of("java/util/Map"),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(support.isEmulatedCoreClassOrInterface("java/util/Map")).isTrue();
assertThat(support.isEmulatedCoreClassOrInterface("java/util/Map$$Lambda$17")).isFalse();
@@ -135,6 +142,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of(),
ImmutableList.of("java/util/Collection"),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(
support.getCoreInterfaceRewritingTarget(
@@ -171,6 +179,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of(),
ImmutableList.of("java/util/Collection"),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(
support.getCoreInterfaceRewritingTarget(
@@ -199,6 +208,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of(),
ImmutableList.of("java/util/Map"),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(
support.getCoreInterfaceRewritingTarget(
@@ -235,6 +245,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of(),
ImmutableList.of("java/util/Comparator"),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(
support.getCoreInterfaceRewritingTarget(
@@ -259,6 +270,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of("java/util/"),
ImmutableList.of(),
+ ImmutableList.of(),
ImmutableList.of());
// regular invocations of default methods: ignored
@@ -328,6 +340,7 @@ public class CoreLibrarySupportTest {
null,
ImmutableList.of("java/util/concurrent/"), // should return null for these
ImmutableList.of("java/util/Map"),
+ ImmutableList.of(),
ImmutableList.of());
assertThat(
support.getCoreInterfaceRewritingTarget(
@@ -346,4 +359,33 @@ public class CoreLibrarySupportTest {
true))
.isNull();
}
+
+ @Test
+ public void testGetCoreInterfaceRewritingTarget_excludedMethodIgnored() throws Exception {
+ CoreLibrarySupport support =
+ new CoreLibrarySupport(
+ new CoreLibraryRewriter(""),
+ Thread.currentThread().getContextClassLoader(),
+ null,
+ ImmutableList.of(),
+ ImmutableList.of("java/util/Collection"),
+ ImmutableList.of(),
+ ImmutableList.of("java/util/Collection#removeIf"));
+ assertThat(
+ support.getCoreInterfaceRewritingTarget(
+ Opcodes.INVOKEINTERFACE,
+ "java/util/List",
+ "removeIf",
+ "(Ljava/util/function/Predicate;)Z",
+ true))
+ .isNull();
+ assertThat(
+ support.getCoreInterfaceRewritingTarget(
+ Opcodes.INVOKEVIRTUAL,
+ "java/util/ArrayList",
+ "removeIf",
+ "(Ljava/util/function/Predicate;)Z",
+ false))
+ .isNull();
+ }
}
diff --git a/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java b/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java
index d998aa27f8..95d7b41105 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java
+++ b/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java
@@ -38,7 +38,8 @@ public class CorePackageRenamerTest {
null,
ImmutableList.of("java/time/"),
ImmutableList.of(),
- ImmutableList.of("java/util/A#m->java/time/B")));
+ ImmutableList.of("java/util/A#m->java/time/B"),
+ ImmutableList.of()));
MethodVisitor mv = renamer.visitMethod(0, "test", "()V", null, null);
mv.visitMethodInsn(