From 161ab7af0434978ad3a9512293a032861a18e16e Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 2 Dec 2015 13:53:46 -0800 Subject: Change FinalizeTest to use helper function Old way kept the object live in a vreg. Bug: 25851249 (cherry picked from commit cf3d432790a78b7d81da656f9a666f3d1ce4962c) Change-Id: I3cefd317e23c602c6c74dd866f0831161ef10962 (cherry picked from commit 8210c23a598b363e89d6cd32dedeeae673bf9212) --- luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java b/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java index ef303bd..d71b5b0 100644 --- a/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java +++ b/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java @@ -69,13 +69,18 @@ public final class FinalizeTest extends TestCase { static class X {} - // http://b/issue?id=2136462 - public void testBackFromTheDead() throws Exception { + // Helper function since we do not want a vreg to keep the allocated object live. + // For b/25851249 + private void exceptionInConstructor() { try { new ConstructionFails(); } catch (AssertionError expected) { } + } + // http://b/issue?id=2136462 + public void testBackFromTheDead() throws Exception { + exceptionInConstructor(); FinalizationTester.induceFinalization(); assertTrue("object whose constructor threw was not finalized", ConstructionFails.finalized); } -- cgit v1.1