RFR: 8188055: (ref) Add Reference::refersTo predicate [v5]

David Holmes david.holmes at oracle.com
Tue Oct 20 06:09:05 UTC 2020


On 20/10/2020 3:26 pm, Kim Barrett wrote:
> On Tue, 20 Oct 2020 03:25:45 GMT, Mandy Chung <mchung at openjdk.org> wrote:
> 
>> @kimbarrett your reworded text is okay. I think "if it initially had some other referent value" can be dropped.
>>
>> For a `Reference` constructed with a `null` referent, we can clarify in the spec that such reference object will never
>> get cleared and enqueued. I suggest to file a separate issue to follow up.
> 
> I don't think that clause can be dropped, because of explicit clearing (by clear() or enqueue()) rather than by the
> GC.  If the reference was constructed with a null referent, ref.refersTo(null) cannot tell whether ref.clear() has been
> called.

I think that can be addressed by considering a Reference created with a 
null referent to be immediately cleared.

But the more we discuss this the more I think allowing an initial null 
referent was a mistake in the first place. :(

Cheers,
David

> -------------
> 
> PR: https://git.openjdk.java.net/jdk/pull/498
> 


More information about the core-libs-dev mailing list