ART: Try to make 059-finalizer-throw less flaky
Avoid some heavier work in the finalizer.
Bug: 64710194
Test: art/test/testrunner/testrunner.py -b --host -t 059
Change-Id: Ic538d75f84815f24a0e612adbe29c7428b33356e
diff --git a/test/059-finalizer-throw/expected.txt b/test/059-finalizer-throw/expected.txt
index cbc9ece..f19011b 100644
--- a/test/059-finalizer-throw/expected.txt
+++ b/test/059-finalizer-throw/expected.txt
@@ -1,2 +1,3 @@
+Starting
In finalizer
done
diff --git a/test/059-finalizer-throw/src/Main.java b/test/059-finalizer-throw/src/Main.java
index 3bfbc2d..da5190a 100644
--- a/test/059-finalizer-throw/src/Main.java
+++ b/test/059-finalizer-throw/src/Main.java
@@ -25,11 +25,18 @@
static Object waiter = new Object();
static volatile boolean didFinal = false;
+ private volatile static Throwable preallocatedException;
+
static void createAndForget() {
Main main = new Main();
}
public static void main(String[] args) {
+ // Preallocate exception to lighten the load in the time-sensitive section.
+ preallocatedException = new InterruptedException("whee");
+ // Print out something to avoid effects of being the first to write.
+ System.out.println("Starting");
+
createAndForget();
System.gc();
@@ -65,6 +72,6 @@
didFinal = true;
- throw new InterruptedException("whee");
+ throw preallocatedException;
}
}