You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Li-Gang Wang (JIRA)" <ji...@apache.org> on 2007/05/21 08:45:16 UTC

[jira] Updated: (HARMONY-3917) [DRLVM][test]gc.WeakReferenceTest & gc.PhantomReferenceTest in drlvm smoke test expect more than Java API spec requires

     [ https://issues.apache.org/jira/browse/HARMONY-3917?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Li-Gang Wang updated HARMONY-3917:
----------------------------------

    Attachment: 01_weakref.patch

In order to let them pass, I submitted the patch as a temporary fix in VM.

> [DRLVM][test]gc.WeakReferenceTest & gc.PhantomReferenceTest in drlvm smoke test expect more than Java API spec requires
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3917
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3917
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Win/Linux 32/64
>            Reporter: Li-Gang Wang
>         Attachments: 01_weakref.patch
>
>
> The two test cases metioned in title have the following code segment:
>     public static void main(String[] args) throws Exception {
>         ReferenceQueue queue = new ReferenceQueue();
>         Object referent = new WeakReferenceTest();
>         Reference ref = new WeakReference(referent, queue);
>         if (ref.get() != referent) {
>             System.out.println("FAIL: can't get weak referent");
>             return;
>         }
>         // drop strong reference
>         referent = null;
>         System.gc();
>         
>         // run finalization to be sure that the reference is enqueued
>         System.runFinalization();
>         
>         Reference enqueued;
>         enqueued = queue.poll();
>         if (enqueued == null) {
>             System.out.println("FAIL: reference was not enqueued");
>             return;
>         }
>         if (ref.get() != null) {
>             System.out.println("FAIL: reference was not cleared.");
>             return;
>         }
>         if (enqueued.get() != null) {
>             System.out.println("FAIL: reference was not cleared.");
>             return;
>         }
>         System.out.println("PASS");
>     }
> They assume the weak reference has been enqueued after System.gc() and System.runFinalization() are called. In fact in spec the first API does not guarantee that every unused object in heap is recycled, and the second API does not guarantee every weak reference is enqueued if its referent becomes weakly reachable. This issue has been discussed in Harmony mailing list. Its title is
> [classlib][testcase] should weakreference be queued in runFinalization()? 
> Because of their wrong assumption, they may fail intermittently. I suggest them to be rewritten according to the spec.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.