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

ReferenceQueue.remove(timeout) waits less than required

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5.1
    • Verified



      Name: akC45999 Date: 09/10/99



      public instance method remove(long timeout) described in Java 2
      Platform v1.3 Specification, class java.lang.ref.ReferenceQueue, as:

      " public Reference remove(long timeout) throws IllegalArgumentException,
                                                     InterruptedException
        Removes the next reference object in this queue, blocking until either
        one becomes available or the given timeout period expires.
        Parameters: timeout - If positive, block for up timeout milliseconds
        while waiting for a reference to be added to this queue..."
        
      runing on win32 platform sometimes returns in time less than timeout
      milliseconds.

      The following program returns the following results on the following
      platforms and JDK builds:

      WinNT HotSpotVM classic VM
      jdk1.3O PASS FAIL
      jdk1.30E PASS PASS
      jdk1.3N PASS PASS

      Win98 HotSpotVM classic VM
      jdk1.3O FAIL FAIL
      jdk1.30E FAIL FAIL
      jdk1.3N FAIL FAIL

      Win95 HotSpotVM classic VM
      jdk1.3O FAIL FAIL
      jdk1.30E FAIL FAIL
      jdk1.3N FAIL FAIL

      Sparc HotSpotVM classic VM
      jdk1.3O PASS PASS
      jdk1.30E PASS PASS
      jdk1.3N PASS PASS

      The program sometimes return FAIL runing with jdk1.2 also.
      The result PASS means the program was run and returned PASS at
      least 5 times.

      results on Win95:
      C:\TMP\java -version
      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)
      C:\TMP\java Remove
      FAIL, remove=1500000, actually was blocked for 1499790 ms
      FAIL, remove=600000, actually was blocked for 599900 ms
      FAIL, remove=15000, actually was blocked for 14990 ms
      PASS

      ------------------------------------------------- program code
       import java.lang.ref.*;

       public class Remove {
           public static final long TIMEOUT1 = 1500000l;
           public static final long TIMEOUT2 = 600000l;
           public static final long TIMEOUT3 = 15000l;
           public static final long TIMEOUT4 = 100l;

           public static void main(String[] args) {
               StartRemove(TIMEOUT1);
               StartRemove(TIMEOUT2);
               StartRemove(TIMEOUT3);
               StartRemove(TIMEOUT4);
           }

           public static void StartRemove(long timeout){
               long startTime, timeSuspended;
               try {
               ReferenceQueue queue = new ReferenceQueue();
               startTime = System.currentTimeMillis();

               //empty queue, remove(timeout) blocks for timeout ms
               queue.remove(timeout);

               timeSuspended = System.currentTimeMillis() - startTime;

               if (timeSuspended < timeout) {
                   //remove(timeout) was blocked for the time less
                   //then timeout milliseconds
                   System.out.println("FAIL, timeout=" + timeout +
                   ", actually was blocked for " + timeSuspended + "ms");
                   return;
               }
               } catch (Throwable e) {
                   System.out.println("exception " + e + " was thrown");
                   return;
               }
               System.out.println("PASS");
               return;
           }
      }//end of class
      --------------------------------------------------------------

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

      Name: akC45999 Date: 09/19/99


      The following JCK-13beta test is failed due to this bug:
       api/java_lang/ref/ReferenceQueue/index.html#ReferenceQueue0200


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

            mmcclosksunw Michael Mccloskey (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: