Add test to check against sharpening optimization

After b/214850438 we took a second look at the sharpening optimization.
While it seems doable, it is not straightforward. We are adding a
comment and a test to make sure we are not mistakenly enabling it.

Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Bug: 214850438
Bug: 154012332
Change-Id: Ic619934cdd4cd322a31afce60b9becbfa4338e81
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index 1fd76f7..8794d5a 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -283,6 +283,12 @@
       // We actually cannot reference this class, we're forced to bail.
       // We cannot reference this class with Bss, as the entrypoint will lookup the class
       // in the caller's dex file, but that dex file does not reference the class.
+      // TODO(solanes): We could theoretically enable this optimization for kBssEntry* but this
+      // requires some changes to the entrypoints, particularly artResolveTypeFromCode and
+      // artResolveTypeAndVerifyAccessFromCode. Currently, they assume that the `load_class`'s
+      // Dexfile and the `dex_compilation_unit` DexFile is the same and will try to use the type
+      // index in the incorrect DexFile by using the `caller`'s DexFile. A possibility is to add
+      // another parameter to it pointing to the correct DexFile to use.
       return HLoadClass::LoadKind::kInvalid;
     }
   }
diff --git a/test/552-checker-sharpening/src-multidex/Multi.java b/test/552-checker-sharpening/src-multidex/Multi.java
new file mode 100644
index 0000000..c360cc7
--- /dev/null
+++ b/test/552-checker-sharpening/src-multidex/Multi.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+public class Multi {
+  /// CHECK-START: java.lang.String Multi.localToHexString() builder (after)
+  /// CHECK-NOT:   LoadClass
+
+  /// CHECK-START: java.lang.String Multi.localToHexString() builder (after)
+  /// CHECK:       InvokeStaticOrDirect method_name:Main.$noinline$toHexString method_load_kind:BssEntry clinit_check:implicit
+  public static String localToHexString() {
+    return MainExtension.$noinline$toHexString(42);
+  }
+}
diff --git a/test/552-checker-sharpening/src/Main.java b/test/552-checker-sharpening/src/Main.java
index 657cc93..15ff8a6 100644
--- a/test/552-checker-sharpening/src/Main.java
+++ b/test/552-checker-sharpening/src/Main.java
@@ -224,3 +224,6 @@
 
 class Other {
 }
+
+class MainExtension extends Main {
+}