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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b32
    • CPU:
      generic, sparc
    • OS:
      generic, solaris_2.5.1
    • Verification:
      Verified

      Description



      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");
          }
        }
       ----------------------------------------------------
        
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mr Mark Reinhold
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: