On Tue, 8 Dec 2020 02:36:01 GMT, Mandy Chung <mch...@openjdk.org> wrote:

> `Reference::isEnqueued` method was never implemented as it was initially 
> specified since 1.2. The specification says that it tests if this reference 
> object has been enqueued, but the long-standing behavior is to test if this 
> reference object is in its associated queue, only reflecting the state at the 
> time when this method is executed. The implementation doesn't do what the 
> specification promised, which might cause serious bugs if unnoticed. For 
> example, an application that relies on this method to release critical 
> resources could cause serious performance issues, in particular when this 
> method is misused on Reference objects without an associated queue.  
> `Reference::refersTo(null)` is the better recommended way to test if a 
> Reference object has been cleared.
> 
> This proposes to deprecate `Reference::isEnqueued`.  Also the spec is updated 
> to match the long-standing behavior.
> 
> CSR: https://bugs.openjdk.java.net/browse/JDK-8189386

This change looks good.  There are a couple of tests that are using isEnqueued.
vmTestbase/gc/gctests/ReferencesGC/ReferencesGC.java
jdk/java/lang/ref/ReferenceEnqueue.java
https://bugs.openjdk.java.net/browse/JDK-8257876
(I'm working on this.)

-------------

Marked as reviewed by kbarrett (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1684

Reply via email to