On 2/7/07, Salikh Zakirov <[EMAIL PROTECTED]> wrote:

Gregory Shimansky wrote:
> Elena Semukhina wrote:
>> I managed to reproduce the failure on my Windows XP laptop. W'd
>> suggest that
>> we change the test so that it waits a little after gc() as Pavel
pointed
>> out.
>
> Spec says in [1] that
>
> -------------------
> Some time after the garbage collector determines that the reachability
> of the referent has changed to the value corresponding to the type of
> the reference, it will add the reference to the associated queue. At
> this point, the reference is considered to be enqueued.
> -------------------
>
> The problem is with defining "some time". If spec says nothing about how
> much time later the reference is enqueued, then it is not possible to
> test such event consistently. I am afraid this test is simply incorrect
> and cannot be used.
>
> [1]
>
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ref/package-summary.html

I would suggest defining "some time" as a call to System.runFinalization
().
It's specification does not mention weak references at all, but it is
highly
likely that finalization subsystem is coupled with weak references
handling,
so expectation of references being enqueued together with finalization
is not ungrounded.
At least on DRLVM, this should work.

And again, if the references wasn't enqueued after

   System.gc(); System.runFinalization();

on DRLVM, then it would look like a real bug.


I tried this approach and it seems working on DRLVM. I ran tests many times
and they always passed. Do we all agree to change WeakReferenceTest and
PhantomReferenceTest so that to remove sleep() at all and add
System.runFinalization() instead?

Elena

--
Thanks,
Elena

Reply via email to