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

(ref) JCK 15a tests WeakReference2003 and PhantomReference2010 failing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6
    • core-libs
    • generic
    • generic

      Since switching to testing with JCK 1.5a, I've noticed new intermittently
      failing test cases:

      api/java_lang/ref/WeakReference/index.html#GCEnqueueing Failed. test cases: 7; passed: 5; failed: 2; first test case failure: WeakReference2003

      25264:api/java_lang/ref/PhantomReference/index.html#GCEnqueueing Failed. test cases: 8; passed: 7; failed: 1; first test case failure: PhantomReference2010

      Failures are always intermittent, occur on solaris-sparc, windows-amd64, and
      linux-amd64. The commonality appears to be that test failures only occur
      on multiprocessor machines.

      Here's a distilled standalone test for reproducing the WeakReference failure:

      import java.lang.ref.*;
      public class WeakReference2003 {
          static final long WEAKREF_ENQUEUEING_TIMEOUT = 100000;
          public static void main(String[] args) throws Throwable {
              try {
                  ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
                  WeakReference<Object> refWeak = new WeakReference<Object>(new Object(), queue);

                  System.gc();
                  long startTime = System.currentTimeMillis();
                  while (System.currentTimeMillis() < (startTime + WEAKREF_ENQUEUEING_TIMEOUT)) {
                      System.gc();
                      if (refWeak.isEnqueued() == false) {
                          try {
                              Thread.sleep(100);
                          } catch (InterruptedException i) {
                          }
                          continue;
                      }
                      break;
                  }
                  if (refWeak.isEnqueued() == false) {
      throw new Exception(
      WEAKREF_ENQUEUEING_TIMEOUT/1000 +
      " seconds ellapsed since " +
      "strong ref was removed, but WeakRef was not enqueued"); }
                  if (refWeak.enqueue() == true) {
                      throw new Exception("WeakRef(obj, queue): after GC enqueueing" +
      " enqueue()==true");
                  }
                  return;

              } catch (Throwable e) {
                  throw new Exception("Unexpected " + e + " was thrown");
              }
          }
      }

      This test fails for me about 50% of the time on my 2-cpu solaris-sparc machine.
      ###@###.### 2005-1-21 18:17:34 GMT

            mr Mark Reinhold
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: