Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4342187

java.lang.ref.ReferenceQueue: method poll() works incorrectly

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_7

      Description



      Name: ooR10006 Date: 05/31/2000


      While GC is enqueueing significantly large number of Soft or Weak or Phantom
      references each registered with own queue and some references are already
      enqueued, i.e. SoftRef.isEnqueued() returns true, method poll() invoked for
      corresponding queues sometimes returns null instead of reference to
      Soft or Weak or PhantomReference object enqueued.
      Method remove() or remove(long) used instead of poll() returns correct
      reference.
      Decreasing number of created Soft references and queues makes the test pass.
      The test fails with HotSpot and jdk1.3fcsC and jdk1.4.0beta-b11 on Solaris,
      but passes with classic VM jdk1.2.2, jdk1.3fcsC and jdk1.4.0beta-b11 on Solaris.

      see the following test and run results:
      ------------------------------------------------------------------------------

      import java.lang.ref.*;

      public class SoftReferenceTest {
        public static final int QUEUE_NUM = 100000;

        public static void main(String args[]) {
              int i = 0;
              ReferenceQueue q[] = new ReferenceQueue[QUEUE_NUM];
              SoftReference r[] = new SoftReference[QUEUE_NUM];
      Object obj = new Object();

              //create QUEUE_NUM SoftRefs each with own
              //queue to one object
              for (i = 0; i < QUEUE_NUM; ++i){
                  q[i] = new ReferenceQueue();
                  r[i] = new SoftReference(obj, q[i]);
              }
              obj = null;
              System.gc();
              for (i=0; i < QUEUE_NUM; ++i){
                  if(r[i].isEnqueued() == true){
      if (q[i].poll() == null){
      System.out.println("FAILED");
      return; // FAILED
      }
                  }
              }
              System.out.println("PASSED");
              return; // PASSED
        }
      }

      % jdk1.3.0fcsC/solaris/bin/java -classic SoftReferenceTest
      PASSED
      % jdk1.2.2/solaris/bin/java SoftReferenceTest
      PASSED
      % jdk1.4.0beta-b11/solaris/bin/java SoftReferenceTest
      FAILED
      % jdk1.3.0fcsC/solaris/bin/java SoftReferenceTest
      FAILED
      %


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mr Mark Reinhold
              Reporter:
              ovosunw Ovo Ovo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: