ART: Remove binary dependencies in 952-invoke-custom-lookup

Moves 952-invoke-custom-lookup into 952-invoke-custom using ASM
annotations to generate the necessary bootstrap metadata.

Bug: 73807070
Test: art/test/run-test --host 952
Change-Id: I07ade94b9106d3ba589c3c606b42a68eda823385
diff --git a/test/952-invoke-custom-lookup/build b/test/952-invoke-custom-lookup/build
deleted file mode 100644
index f3fe95c..0000000
--- a/test/952-invoke-custom-lookup/build
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# make us exit on a failure
-set -e
-
-# This test uses previously prepared dex and jar files. They need to
-# be re-packaged to match the files that the run-test-jar script
-# expects.
-if [[ $@ != *"--jvm"* ]]; then
-  zip ${TEST_NAME}.jar classes.dex
-else
-  unzip -d classes classes.jar
-fi
diff --git a/test/952-invoke-custom-lookup/classes.dex b/test/952-invoke-custom-lookup/classes.dex
deleted file mode 100644
index 670d93d..0000000
--- a/test/952-invoke-custom-lookup/classes.dex
+++ /dev/null
Binary files differ
diff --git a/test/952-invoke-custom-lookup/classes.jar b/test/952-invoke-custom-lookup/classes.jar
deleted file mode 100644
index aa6a1f6..0000000
--- a/test/952-invoke-custom-lookup/classes.jar
+++ /dev/null
Binary files differ
diff --git a/test/952-invoke-custom-lookup/expected.txt b/test/952-invoke-custom-lookup/expected.txt
deleted file mode 100644
index 0da2b86..0000000
--- a/test/952-invoke-custom-lookup/expected.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-NAME: 1
-CALLER: Main
-CALLER CLASS: class Main
-THIS CLASS: class com.android.tools.r8.maindexlist.desugar.BootstrapHolder
-invokedynamic target on Main
-NAME: 2
-CALLER: Main
-CALLER CLASS: class Main
-THIS CLASS: class com.android.tools.r8.maindexlist.desugar.BootstrapHolder
-invokedynamic target on BootstrapHolder
diff --git a/test/952-invoke-custom-lookup/info.txt b/test/952-invoke-custom-lookup/info.txt
deleted file mode 100644
index 3bfe87d..0000000
--- a/test/952-invoke-custom-lookup/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-A temporary test for the lookup class used for invoke-custom (see b/73056094).
diff --git a/test/952-invoke-custom/expected.txt b/test/952-invoke-custom/expected.txt
index 61793d1..be01c45 100644
--- a/test/952-invoke-custom/expected.txt
+++ b/test/952-invoke-custom/expected.txt
@@ -11,4 +11,5 @@
 100
 -9000
 9000
+TestLinkerUnrelatedBSM
 Winners 1 Votes 16
diff --git a/test/952-invoke-custom/src/Main.java b/test/952-invoke-custom/src/Main.java
index 93bc8d3..2e1db82 100644
--- a/test/952-invoke-custom/src/Main.java
+++ b/test/952-invoke-custom/src/Main.java
@@ -17,7 +17,6 @@
 import java.lang.invoke.CallSite;
 import java.lang.invoke.MethodType;
 import java.lang.invoke.MutableCallSite;
-import java.lang.reflect.InvocationTargetException;
 
 public class Main extends TestBase {
 
@@ -85,6 +84,7 @@
         TestUninitializedCallSite();
         TestLinkerMethodMinimalArguments();
         TestLinkerMethodMultipleArgumentTypes();
+        TestLinkerUnrelatedBSM.test();
         TestInvokeCustomWithConcurrentThreads();
     }
 }
diff --git a/test/952-invoke-custom/src/TestLinkerMethodMinimalArguments.java b/test/952-invoke-custom/src/TestLinkerMethodMinimalArguments.java
index 5310488..74ac3cd 100644
--- a/test/952-invoke-custom/src/TestLinkerMethodMinimalArguments.java
+++ b/test/952-invoke-custom/src/TestLinkerMethodMinimalArguments.java
@@ -44,7 +44,8 @@
         argumentTypes = {int.class, int.class}
     )
     private static int add(int a, int b) {
-        throw new UnsupportedOperationException("Should be invoking _add(a, b)");
+        assertNotReached();
+        return -1;
     }
 
     @SuppressWarnings("unused")
diff --git a/test/952-invoke-custom/src/TestLinkerMethodMultipleArgumentTypes.java b/test/952-invoke-custom/src/TestLinkerMethodMultipleArgumentTypes.java
index 6ae7abb..acb6986 100644
--- a/test/952-invoke-custom/src/TestLinkerMethodMultipleArgumentTypes.java
+++ b/test/952-invoke-custom/src/TestLinkerMethodMultipleArgumentTypes.java
@@ -67,7 +67,8 @@
         argumentTypes = {int.class, int.class}
     )
     private static int add(int a, int b) {
-        throw new UnsupportedOperationException("Should be invoking _add(a, b)");
+        assertNotReached();
+        return -1;
     }
 
     @SuppressWarnings("unused")
diff --git a/test/952-invoke-custom/src/TestLinkerUnrelatedBSM.java b/test/952-invoke-custom/src/TestLinkerUnrelatedBSM.java
new file mode 100644
index 0000000..3a63b33
--- /dev/null
+++ b/test/952-invoke-custom/src/TestLinkerUnrelatedBSM.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import annotations.CalledByIndy;
+import annotations.Constant;
+import annotations.LinkerMethodHandle;
+import annotations.MethodHandleKind;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+class TestLinkerUnrelatedBSM extends TestBase {
+    @CalledByIndy(
+        invokeMethodHandle =
+                @LinkerMethodHandle(
+                    kind = MethodHandleKind.INVOKE_STATIC,
+                    enclosingType = UnrelatedBSM.class,
+                    argumentTypes = {
+                        MethodHandles.Lookup.class,
+                        String.class,
+                        MethodType.class,
+                        Class.class
+                    },
+                    name = "bsm"
+                ),
+        methodHandleExtraArgs = {@Constant(classValue = TestLinkerUnrelatedBSM.class)},
+        name = "_addf",
+        returnType = float.class,
+        argumentTypes = {float.class, float.class}
+    )
+    private static float addf(float a, float b) {
+        assertNotReached();
+        return Float.MIN_VALUE;
+    }
+
+    public static float _addf(float a, float b) {
+        return a + b;
+    }
+
+    @CalledByIndy(
+        invokeMethodHandle =
+                @LinkerMethodHandle(
+                    kind = MethodHandleKind.INVOKE_STATIC,
+                    enclosingType = UnrelatedBSM.class,
+                    argumentTypes = {
+                        MethodHandles.Lookup.class,
+                        String.class,
+                        MethodType.class,
+                        Class.class
+                    },
+                    name = "bsm"
+                ),
+        methodHandleExtraArgs = {@Constant(classValue = TestLinkerUnrelatedBSM.class)},
+        name = "_subf",
+        returnType = float.class,
+        argumentTypes = {float.class, float.class}
+    )
+    private static float subf(float a, float b) {
+        assertNotReached();
+        return Float.MIN_VALUE;
+    }
+
+    private static float _subf(float a, float b) {
+        return a - b;
+    }
+
+    public static void test() {
+        System.out.println(TestLinkerUnrelatedBSM.class.getName());
+        assertEquals(2.5f, addf(2.0f, 0.5f));
+        assertEquals(1.5f, subf(2.0f, 0.5f));
+    }
+}
diff --git a/test/952-invoke-custom/src/UnrelatedBSM.java b/test/952-invoke-custom/src/UnrelatedBSM.java
new file mode 100644
index 0000000..1611a81
--- /dev/null
+++ b/test/952-invoke-custom/src/UnrelatedBSM.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+class UnrelatedBSM {
+    static CallSite bsm(
+            MethodHandles.Lookup lookup, String name, MethodType methodType, Class<?> target)
+            throws Throwable {
+        MethodHandle mh = lookup.findStatic(target, name, methodType);
+        return new ConstantCallSite(mh);
+    }
+}