Java.Util.Function is broken on API 26+

Bug: 139398549
Change-Id: I9ef2d4a1276e409c8f9f134c506a0117b18ddfeb
diff --git a/src/test/java/com/android/tools/r8/shaking/FunctionTest.java b/src/test/java/com/android/tools/r8/shaking/FunctionTest.java
new file mode 100644
index 0000000..0e87547
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/shaking/FunctionTest.java
@@ -0,0 +1,82 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.shaking;
+
+import static org.hamcrest.core.StringContains.containsString;
+
+import com.android.tools.r8.NeverInline;
+import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.ToolHelper.DexVm.Version;
+import com.android.tools.r8.utils.StringUtils;
+import java.util.function.Function;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class FunctionTest extends TestBase {
+
+  private static final String expectedOutput = StringUtils.lines("Hello, world", "Hello, world");
+  private final TestParameters parameters;
+
+  @Parameterized.Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    return getTestParameters().withDexRuntimesStartingFromIncluding(Version.V8_1_0).build();
+  }
+
+  public FunctionTest(TestParameters parameters) {
+    this.parameters = parameters;
+  }
+
+  @Test
+  public void testD8() throws Exception {
+    testForD8()
+        .addInnerClasses(FunctionTest.class)
+        .run(parameters.getRuntime(), FunctionTest.TestClass.class)
+        .assertSuccessWithOutput(expectedOutput);
+  }
+
+  @Test
+  public void testR8Working() throws Exception {
+    testForR8(parameters.getBackend())
+        .addKeepMainRule(TestClass.class)
+        .noTreeShaking()
+        .noMinification()
+        .enableInliningAnnotations()
+        .addInnerClasses(FunctionTest.class)
+        .run(parameters.getRuntime(), TestClass.class)
+        .assertSuccessWithOutput(expectedOutput);
+  }
+
+  @Test
+  public void testR8Broken() throws Exception {
+    testForR8(parameters.getBackend())
+        .addKeepMainRule(TestClass.class)
+        .enableInliningAnnotations()
+        .addInnerClasses(FunctionTest.class)
+        .run(parameters.getRuntime(), TestClass.class)
+        // TODO(b/139398549): Change this to assertSuccessWithOutput(expectedOutput).
+        .assertFailure()
+        .assertStderrMatches(
+            containsString(
+                "Exception in thread \"main\" java.lang.AbstractMethodError: abstract method"
+                    + " \"java.lang.Object"
+                    + " java.util.function.Function.apply(java.lang.Object)\""));
+  }
+
+  static class TestClass {
+
+    @NeverInline
+    private static String applyFunction(Function<String, String> f) {
+      return f.apply("Hello, world");
+    }
+
+    public static void main(String[] args) {
+      System.out.println(applyFunction(s -> s + System.lineSeparator() + s));
+    }
+  }
+}