On 05.12.15 21:23, Peter Levart wrote:
Digging up the src.jar of JDK 1.2.2, here's what the constructor of
PhantomReference looked like:
/**
* Creates a new phantom reference that refers to the given object and
* is registered with the given queue.
*
* @throws NullPointerException If the <code>queue</code> argument
* is <code>null</code>
*/
public PhantomReference(Object referent, ReferenceQueue q) {
super(referent, q);
}
...so it seems Mark wanted PhantomReference constructor to throw NPE.
But implementation did not do that (here's also the constructor of
Reference):
Reference(Object referent, ReferenceQueue queue) {
this.referent = referent;
if (referent == null) {
/* Immediately make this instance inactive */
this.queue = ReferenceQueue.NULL;
this.next = this;
} else {
this.queue = (queue == null) ? ReferenceQueue.NULL : queue;
this.next = null;
}
}
...and so the spec. has probably been modified to follow the standing
behavior.
Looks like it was updated in jdk5:
https://bugs.openjdk.java.net/browse/JDK-4239039
--
Best regards, Sergey.