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)
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 @@
 
     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);
     }