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

(ref) (spec) Reference-object constructors allow null queues

XMLWordPrintable

    • b32
    • generic, sparc
    • generic, solaris_2.5.1
    • Verified



      Name: akC45999 Date: 05/18/99


         
         The Java 2 Standard Edition API Specification, v1.2.1 chapter
         "Class WeakReference" reads:
          ...
         public WeakReference(Object referent,
                              ReferenceQueue q)
         
             Creates a new weak reference that refers to the
             given object and is registered with the given queue.
             Throws:
                NullPointerException - If the queue argument is null
         ...
         
         But the attached test code shows that no exceptions are thrown at all.
         The same result is for SoftReference and PhantomReference constructors.
       
         The bug is reproduced also under JDK1.2, JDK1.2.1, JDK1.2.2P, JDK1.3C.
         
         Code example:
       
       novo51% java -version
       java version "1.2.1"
       Classic VM (build JDK-1.2.1-L, green threads, sunwjit)
       novo51% javac WeakReference0201.java
       novo51% java WeakReference0201
       Failed
       novo51%
        
       ---------------- WeakReference0201.java --------------
       
        import java.io.PrintStream;
        import java.lang.ref.*;
        
        public class WeakReference0201 {
        
          public static void main (String args[]) {
            try {
                new WeakReference(new Object(), null);
            } catch (NullPointerException e) {
                System.out.println("Passed");
                return;
             }
            System.out.println("Failed");
          }
        }
       ----------------------------------------------------
        
      ======================================================================

            mr Mark Reinhold
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: