public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Jeroen Frijters" <jeroen@sumatra.nl>
To: "Mauve Discuss" <mauve-discuss@sources.redhat.com>
Subject: PhantomReference
Date: Fri, 26 Nov 2004 14:09:00 -0000	[thread overview]
Message-ID: <D92197D0A6547B44A1567814F851FA6802A576@LEMBU.sumatrasoftware.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

Hi,

Like (almost) all GC related tests, the PhantomReference test is
dubious, but I'd to propose the attached changes anyway, which I think
(hope?) will make it more robust on all VMs.

The prints are there to keep the references alive, not really nice to
use print for this, but I couldn't think of any other way that was both
simple and reliable.

Any comments?

Regards,
Jeroen

[-- Attachment #2: phantom.patch --]
[-- Type: application/octet-stream, Size: 1392 bytes --]

Index: gnu/testlet/java/lang/ref/PhantomReference/phantom.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/ref/PhantomReference/phantom.java,v
retrieving revision 1.3
diff -u -r1.3 phantom.java
--- gnu/testlet/java/lang/ref/PhantomReference/phantom.java	18 Apr 2004 15:47:59 -0000	1.3
+++ gnu/testlet/java/lang/ref/PhantomReference/phantom.java	26 Nov 2004 14:05:42 -0000
@@ -56,14 +56,17 @@
 
     // Give the runtime some hints that it should really garbage collect.
     System.gc ();
-    Thread.yield ();
+    System.runFinalization();
     System.gc ();
+    System.runFinalization();
 
     Reference r = q.poll ();
     harness.check (r, null, "live reference");
     harness.check (final_count, 0);
 
-    // Must keep the PhantomReference live.
+    // Must keep the phantom object live.
+    System.out.println(twt);
+
     return wr;
   }
 
@@ -73,6 +76,9 @@
 
     PhantomReference wr = try1 (q, harness);
     System.gc ();
+    System.runFinalization();
+    System.gc ();
+    System.runFinalization();
 
     Reference r = null;
     try
@@ -86,5 +92,8 @@
 
     harness.check (r, wr, "unreachable");
     harness.check (final_count, 1, "object finalized");
+
+    // Make sure we're not GCed while running the test.
+    System.out.println(this);
   }
 }

                 reply	other threads:[~2004-11-26 14:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D92197D0A6547B44A1567814F851FA6802A576@LEMBU.sumatrasoftware.com \
    --to=jeroen@sumatra.nl \
    --cc=mauve-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).