ART: Fix test 904
Prefetch class names to avoid allocation for logging.
Bug: 31684277
Test: m ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT=true test-art-host-run-test-904-object-allocation
Change-Id: I8d12ea1a2b15680995af84d243de4d07d22bede5
diff --git a/test/904-object-allocation/src/Main.java b/test/904-object-allocation/src/Main.java
index 63f7f89..f15c1c2 100644
--- a/test/904-object-allocation/src/Main.java
+++ b/test/904-object-allocation/src/Main.java
@@ -23,9 +23,22 @@
// Use a list to ensure objects must be allocated.
ArrayList<Object> l = new ArrayList<>(100);
+ prefetchClassNames();
+
doTest(l);
}
+ // Pre-resolve class names so the strings don't have to be allocated as a side effect of
+ // callback printing.
+ private static void prefetchClassNames() {
+ Object.class.getName();
+ Integer.class.getName();
+ Float.class.getName();
+ Short.class.getName();
+ Byte.class.getName();
+ Double.class.getName();
+ }
+
public static void doTest(ArrayList<Object> l) throws Exception {
setupCallback();