harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiao-Feng Li" <xiaofeng...@gmail.com>
Subject [classlib][testcase] should weakreference be queued in runFinalization()?
Date Fri, 13 Apr 2007 02:37:14 GMT
In classlib tests "gc.PhantomReferenceTest" and
"tests.api.java.lang.ref.ReferenceTest", they expect weakreference
objects be queued after System.runFinalization(). Is this correct? In
my understanding of the spec, there is no requirement on this

The tests do like this:

//wr is the weakreference, whose referent is only weakly reachable.
//rq is the reference queue


ref = rq.poll();

assertTrue("Unexpected ref2", ref == wr);
assertNotNull("Object not garbage collected.", ref);
assertNull("Object could not be reclaimed.", ref.get());

After runFinalization(), it requires the queue has the weakreference.
Actually it has requirement on System.gc() as well, requiring it to
identify the weakly reachable object accurately.

In my understanding of the spec, this kind of tests are wrong. It
forces the GC to do something not required by spec.

How do you think?


View raw message