Skip to content
Permalink
Browse files
8052260: Reference.isEnqueued() spec does not match the long-standing…
… behavior returning true iff it's in the ref queue

Reviewed-by: kbarrett, alanb
  • Loading branch information
Mandy Chung committed Dec 9, 2020
1 parent 6dd06ad commit 5f0334121153332873f952fdc6828b9926171bbe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
@@ -411,14 +411,35 @@ void clearInactiveFinalReference() {
/* -- Queue operations -- */

/**
* Tells whether or not this reference object has been enqueued, either by
* the program or by the garbage collector. If this reference object was
* not registered with a queue when it was created, then this method will
* always return {@code false}.
*
* @return {@code true} if and only if this reference object has
* been enqueued
* Tests if this reference object is in its associated queue, if any.
* This method returns {@code true} only if all of the following conditions
* are met:
* <ul>
* <li>this reference object was registered with a queue when it was created; and
* <li>the garbage collector has added this reference object to the queue
* or {@link #enqueue()} is called; and
* <li>this reference object is not yet removed from the queue.
* </ul>
* Otherwise, this method returns {@code false}.
* This method may return {@code false} if this reference object has been cleared
* but not enqueued due to the race condition.
*
* @deprecated
* This method was originally specified to test if a reference object has
* been cleared and enqueued but was never implemented to do this test.
* This method could be misused due to the inherent race condition
* or without an associated {@code ReferenceQueue}.
* An application relying on this method to release critical resources
* could cause serious performance issue.
* An application should use {@link ReferenceQueue} to reliably determine
* what reference objects that have been enqueued or
* {@link #refersTo(Object) refersTo(null)} to determine if this reference
* object has been cleared.
*
* @return {@code true} if and only if this reference object is
* in its associated queue (if any).
*/
@Deprecated(since="16")
public boolean isEnqueued() {
return (this.queue == ReferenceQueue.ENQUEUED);
}
@@ -160,6 +160,7 @@ public void clear() {
*
* @throws UnsupportedOperationException always
*/
@SuppressWarnings("deprecation")
@Override
public final boolean isEnqueued() {
throw new UnsupportedOperationException("isEnqueued");

1 comment on commit 5f03341

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 5f03341 Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.