-
Bug
-
Resolution: Fixed
-
P4
-
1.2.2, 1.3.0, 5.0
-
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");
}
}
----------------------------------------------------
======================================================================
- relates to
-
JDK-5012887 (ref) WeakReference 2-parameter constructor fails to throw NullPointerException
- Closed