This is the mail archive of the
mailing list for the Mauve project.
Re: Mauve patch
- From: Archie Cobbs <archie at dellroad dot org>
- To: Sascha Brawer <brawer at dandelis dot ch>
- Cc: mauve-discuss at sources dot redhat dot com, commit-classpath at gnu dot org
- Date: Tue, 6 Apr 2004 08:46:27 -0500 (CDT)
- Subject: Re: Mauve patch
Sascha Brawer wrote:
> > PhantomReference wr = try1 (q, harness);
> > System.gc ();
> >+ Thread.yield();
> >+ System.gc ();
> > Reference r = null;
> > try
> Does this really guarantee that the finalizer has run? Couldn't this also
> lead to any other thread, such as some VM-internal thread, without
> running the finalizer? If so, you might want to call Object.notify in the
> finalizer and Object.wait at the above code location.
This patch doesn't guarantee anything, and in general it's impossible
to make this test "correct" because the spec allows finalization and
reference enqueuing to happen after arbitrarily long delays.
For example, a JVM that *never* finalizes is still within the spec
(it would probably throw OutOfMemoryError's more readily though).
This patch simply makes the test "correct" for JC (and possibly
some other VM(s) out there). Since there's no way to *ensure* the
finalizer and reference enqueing thread(s) have run, we just try
to give them every opportunity to do so before declaring that their
work should be done.
Archie Cobbs * CTO, Awarix * http://www.awarix.com