Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8269721 | 18 | Mandy Chung | P4 | Resolved | Fixed | b05 |
JDK-8270688 | 17.0.1 | Mandy Chung | P4 | Resolved | Fixed | b03 |
A DESCRIPTION OF THE PROBLEM :
WhenJDK-8188055 added Reference.refersTo, there were some concerns regarding how PhantomReference should behave. In the end it appears PhantomReference.refersTo got the functionality to check whether the reference still refers to an object (at least latest jdk.java.net builds do):
```
Object o = new Object();
PhantomReference<Object> ref = new PhantomReference<>(o, null);
ref.refersTo(null); // false
ref.refersTo(o); // true
```
However the current documentation for PhantomReference does not make this obvious, especially since the documentation for `Reference.get()` says that instead of `get() == ...` one should use `refersTo(...)`, but `PhantomReference.get()` is documented as always returning `null`.
Therefore it would be good to adjust the PhantomReference documentation in the following ways:
- Class documentation section with "The {@code get} method of a phantom reference always returns {@code null}" should mention that `refersTo` can be used.
- Constructor documentation should be rephrased. It might now be a legit use-case to use `null` as queue and call `refersTo` (at least it is not "completely useless" anymore)
- `refersTo` should be overridden to allow mentioning in documentation that this method works for PhantomReference
When
```
Object o = new Object();
PhantomReference<Object> ref = new PhantomReference<>(o, null);
ref.refersTo(null); // false
ref.refersTo(o); // true
```
However the current documentation for PhantomReference does not make this obvious, especially since the documentation for `Reference.get()` says that instead of `get() == ...` one should use `refersTo(...)`, but `PhantomReference.get()` is documented as always returning `null`.
Therefore it would be good to adjust the PhantomReference documentation in the following ways:
- Class documentation section with "The {@code get} method of a phantom reference always returns {@code null}" should mention that `refersTo` can be used.
- Constructor documentation should be rephrased. It might now be a legit use-case to use `null` as queue and call `refersTo` (at least it is not "completely useless" anymore)
- `refersTo` should be overridden to allow mentioning in documentation that this method works for PhantomReference
- backported by
-
JDK-8269721 Clarify the behavior of PhantomReference::refersTo
-
- Resolved
-
-
JDK-8270688 Clarify the behavior of PhantomReference::refersTo
-
- Resolved
-
- csr for
-
JDK-8269688 Clarify the behavior of PhantomReference::refersTo
-
- Closed
-
- relates to
-
JDK-8188055 (ref) Add Reference::refersTo predicate
-
- Resolved
-
(1 links to)