On Tue, 16 Jun 2026 06:19:55 GMT, Alan Bateman <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/ref/Reference.java line 543:
>> 
>>> 541:     Reference(T referent, ReferenceQueue<? super T> queue) {
>>> 542:         if (referent != null) {
>>> 543:             Objects.requireIdentity(referent);
>> 
>> For clarity, should this call be guarded by a  check of 
>> `PreviewFeatures.isEnabled()`?
>
> It's okay to use this API in the implementation of method in java.base (or 
> other "participates in preview" modules). It's no different to when virtual 
> threads were in preview and we have checked for isVirtual in several places 
> of the implementation.

Hello Alan, my comment was more in terms of readability to make it clear at 
this call site that the identity requirement is only applicable when preview 
features is enabled. I don't have a strong preference and it's OK to retain it 
in the current form.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31123#discussion_r3418580945

Reply via email to