RFR: 8071507: (ref) Clear phantom reference as soft and weak references do
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Mon Dec 7 13:49:23 UTC 2015
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.
More information about the core-libs-dev
mailing list