ART: Remove ArtMethod::IsAnnotatedWithPolymorphicSignature

Avoids relying on PolymorphicSignature annotation in determining
whether a method is signature polymorphic.

Bug: 65872996
Test: art/test.py --host -j32
Change-Id: If064b92575bf4e4d7eba5dc5332f780e96054fe2
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 80f5c34..b5e0f66 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -417,6 +417,17 @@
   return GetDeclaringClass()->IsInterface();
 }
 
+bool ArtMethod::IsPolymorphicSignature() {
+  // Methods with a polymorphic signature have constraints that they
+  // are native and varargs and belong to either MethodHandle or VarHandle.
+  if (!IsNative() || !IsVarargs()) {
+    return false;
+  }
+  mirror::Class* cls = GetDeclaringClass();
+  return (cls == WellKnownClasses::ToClass(WellKnownClasses::java_lang_invoke_MethodHandle) ||
+          cls == WellKnownClasses::ToClass(WellKnownClasses::java_lang_invoke_VarHandle));
+}
+
 bool ArtMethod::IsAnnotatedWithFastNative() {
   return IsAnnotatedWith(WellKnownClasses::dalvik_annotation_optimization_FastNative,
                          DexFile::kDexVisibilityBuild,
@@ -429,12 +440,6 @@
                          /* lookup_in_resolved_boot_classes */ true);
 }
 
-bool ArtMethod::IsAnnotatedWithPolymorphicSignature() {
-  return IsAnnotatedWith(WellKnownClasses::java_lang_invoke_MethodHandle_PolymorphicSignature,
-                         DexFile::kDexVisibilityRuntime,
-                         /* lookup_in_resolved_boot_classes */ true);
-}
-
 bool ArtMethod::IsAnnotatedWith(jclass klass,
                                 uint32_t visibility,
                                 bool lookup_in_resolved_boot_classes) {