diff options
| author | 2018-03-27 13:39:25 +0000 | |
|---|---|---|
| committer | 2018-03-27 13:39:25 +0000 | |
| commit | 3615a10cef1e82b92dd2a58a594fc9fe2cf73c70 (patch) | |
| tree | 017b8103b82993614b7d55bd0b2e10a815b62f30 | |
| parent | b006e1fb48bbda59da6029fb7cdb2abae3429a8e (diff) | |
| parent | e37dc6ee0489565f911aeb792d627d942a3ae4cd (diff) | |
Merge "Fix 036-finalizer for JIT-at-first-use gcstress."
| -rw-r--r-- | test/036-finalizer/src/Main.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java index ff6186b240..51d4a81150 100644 --- a/test/036-finalizer/src/Main.java +++ b/test/036-finalizer/src/Main.java @@ -70,15 +70,17 @@ public class Main { return s[0]; } - private static void printWeakReference(WeakReference<FinalizerTest> wimp) { + public static void main(String[] args) { + WeakReference<FinalizerTest> wimp = makeRef(); // Reference ft so we are sure the WeakReference cannot be cleared. + // Note: This is very fragile. It was previously in a helper function but that + // doesn't work for JIT-on-first-use with --gcstress where the object would be + // collected when JIT internally allocates an array. Also adding a scope around + // the keepLive lifetime somehow keeps a non-null `keepLive` around and makes + // the test fail (even when keeping the `null` assignment). b/76454261 FinalizerTest keepLive = wimp.get(); System.out.println("wimp: " + wimpString(wimp)); - } - - public static void main(String[] args) { - WeakReference<FinalizerTest> wimp = makeRef(); - printWeakReference(wimp); + keepLive = null; // Clear the reference. /* this will try to collect and finalize ft */ System.out.println("gc"); |