Update ART tests to handle new System.gc behavior
Changed calls from System.gc to Runtime.getRuntime.gc where it was
necessary.
Required for:
https://android-review.googlesource.com/#/c/80253/
Change-Id: I2b0622585da54229a6248e95d40134b6d18598a9
diff --git a/test/003-omnibus-opcodes/src/InternedString.java b/test/003-omnibus-opcodes/src/InternedString.java
index 804564b..35812e6 100644
--- a/test/003-omnibus-opcodes/src/InternedString.java
+++ b/test/003-omnibus-opcodes/src/InternedString.java
@@ -34,14 +34,14 @@
private static void testDeadInternedString() {
WeakReference<String> strRef = makeWeakString();
- System.gc();
+ Runtime.getRuntime().gc();
// "blahblah" should disappear from the intern list
Main.assertTrue(strRef.get() == null);
}
private static void testImmortalInternedString() {
WeakReference strRef = new WeakReference<String>(CONST.intern());
- System.gc();
+ Runtime.getRuntime().gc();
// Class constant string should be entered to the interned table when
// loaded
Main.assertTrue(CONST == CONST.intern());
@@ -53,7 +53,7 @@
strRef = new WeakReference<String>(s.intern());
// Kill s, otherwise the string object is still accessible from root set
s = "";
- System.gc();
+ Runtime.getRuntime().gc();
Main.assertTrue(strRef.get() == CONST);
}
}
diff --git a/test/003-omnibus-opcodes/src/Main.java b/test/003-omnibus-opcodes/src/Main.java
index 5dcc79c..25050df 100644
--- a/test/003-omnibus-opcodes/src/Main.java
+++ b/test/003-omnibus-opcodes/src/Main.java
@@ -26,7 +26,7 @@
main.run();
/* run through the heap to see if we trashed something */
- System.gc();
+ Runtime.getRuntime().gc();
System.out.println("Done!");
}
diff --git a/test/023-many-interfaces/src/ManyInterfaces.java b/test/023-many-interfaces/src/ManyInterfaces.java
index c4cb4ab..d69a490 100644
--- a/test/023-many-interfaces/src/ManyInterfaces.java
+++ b/test/023-many-interfaces/src/ManyInterfaces.java
@@ -200,7 +200,7 @@
* Clear the heap. The various classes involved should already
* be loaded and ready as a result of instantiating ManyInterfaces.
*/
- System.gc();
+ Runtime.getRuntime().gc();
start = System.nanoTime();
testIface001(obj, iter);
diff --git a/test/030-bad-finalizer/src/Main.java b/test/030-bad-finalizer/src/Main.java
index e19fd3e..330e344 100644
--- a/test/030-bad-finalizer/src/Main.java
+++ b/test/030-bad-finalizer/src/Main.java
@@ -25,12 +25,12 @@
bf = null;
System.out.println("Nulled. Requestion gc.");
- System.gc();
+ Runtime.getRuntime().gc();
for (int i = 0; i < 8; i++) {
BadFinalizer.snooze(4000);
System.out.println("Requesting another GC.");
- System.gc();
+ Runtime.getRuntime().gc();
}
System.out.println("Done waiting.");
diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java
index 4bc7d8d..6195aff 100644
--- a/test/036-finalizer/src/Main.java
+++ b/test/036-finalizer/src/Main.java
@@ -93,7 +93,7 @@
/* this will try to collect and finalize ft */
System.out.println("gc");
- System.gc();
+ Runtime.getRuntime().gc();
System.out.println("wimp: " + wimpString(wimp));
System.out.println("finalize");
@@ -106,7 +106,7 @@
System.out.println("reborn: " + FinalizerTest.mReborn);
System.out.println("wimp: " + wimpString(wimp));
System.out.println("reset reborn");
- System.gc();
+ Runtime.getRuntime().gc();
FinalizerTest.mReborn = FinalizerTest.mNothing;
System.out.println("gc + finalize");
System.gc();
diff --git a/test/067-preemptive-unpark/src/Main.java b/test/067-preemptive-unpark/src/Main.java
index a16219e..2c099b9 100644
--- a/test/067-preemptive-unpark/src/Main.java
+++ b/test/067-preemptive-unpark/src/Main.java
@@ -18,6 +18,7 @@
System.out.println("GC'ing");
System.gc();
+ System.runFinalization();
System.gc();
System.out.println("Asking thread to park");
diff --git a/test/072-precise-gc/src/Main.java b/test/072-precise-gc/src/Main.java
index e049221..f6cd8b1 100644
--- a/test/072-precise-gc/src/Main.java
+++ b/test/072-precise-gc/src/Main.java
@@ -88,7 +88,7 @@
* Getting a zero result here isn't conclusive, but it's a strong
* indicator that precise GC is having an impact.
*/
- System.gc();
+ Runtime.getRuntime().gc();
for (int i = 0; i < wrefs.length; i++) {
if (wrefs[i].get() != null)
diff --git a/test/074-gc-thrash/src/Main.java b/test/074-gc-thrash/src/Main.java
index f85aa4b..78413f3 100644
--- a/test/074-gc-thrash/src/Main.java
+++ b/test/074-gc-thrash/src/Main.java
@@ -232,7 +232,7 @@
for (int i = 0; i < MAX_DEPTH; i++)
strong[i] = null;
- System.gc();
+ Runtime.getRuntime().gc();
for (int i = 0; i < MAX_DEPTH; i++) {
if (weak[i].get() != null) {
diff --git a/test/079-phantom/src/Main.java b/test/079-phantom/src/Main.java
index 9c459c9..c54bc0b 100644
--- a/test/079-phantom/src/Main.java
+++ b/test/079-phantom/src/Main.java
@@ -38,29 +38,29 @@
public void run() {
createBitmaps();
- System.gc();
+ Runtime.getRuntime().gc();
sleep(250);
mBitmap2.drawAt(0, 0);
System.out.println("nulling 1");
mBitmap1 = null;
- System.gc();
+ Runtime.getRuntime().gc();
sleep(500);
System.out.println("nulling 2");
mBitmap2 = null;
- System.gc();
+ Runtime.getRuntime().gc();
sleep(500);
System.out.println("nulling 3");
mBitmap3 = null;
- System.gc();
+ Runtime.getRuntime().gc();
sleep(500);
System.out.println("nulling 4");
mBitmap4 = null;
- System.gc();
+ Runtime.getRuntime().gc();
sleep(500);
Bitmap.shutDown();
diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java
index 4d6aca3..a532141 100644
--- a/test/083-compiler-regressions/src/Main.java
+++ b/test/083-compiler-regressions/src/Main.java
@@ -172,7 +172,7 @@
}
static void b2302318Test() {
- System.gc();
+ Runtime.getRuntime().gc();
SpinThread slow = new SpinThread(Thread.MIN_PRIORITY);
SpinThread fast1 = new SpinThread(Thread.NORM_PRIORITY);
@@ -188,7 +188,7 @@
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {/*ignore */}
- System.gc();
+ Runtime.getRuntime().gc();
System.out.println("b2302318 passes");
}
diff --git a/test/087-gc-after-link/src/Main.java b/test/087-gc-after-link/src/Main.java
index c99a7d5..e0a187a 100644
--- a/test/087-gc-after-link/src/Main.java
+++ b/test/087-gc-after-link/src/Main.java
@@ -170,7 +170,7 @@
ite.printStackTrace();
}
}
- System.gc();
+ Runtime.getRuntime().gc();
System.out.println("GC complete.");
}
}
diff --git a/test/109-suspend-check/src/Main.java b/test/109-suspend-check/src/Main.java
index d92b9e5..ae10576 100644
--- a/test/109-suspend-check/src/Main.java
+++ b/test/109-suspend-check/src/Main.java
@@ -28,7 +28,7 @@
doWhileLoop.start();
garbage.start();
for (int i = 0; i < TEST_TIME; i++) {
- System.gc();
+ Runtime.getRuntime().gc();
System.out.println(".");
sleep(1000);
}