On Tue, 16 Jun 2026 05:36:04 GMT, Jaikiran Pai <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/ref/Cleaner.java line 221:
>>
>>> 219: * @param action a {@code Runnable} to invoke when the object
>>> becomes phantom reachable
>>> 220: * @return a {@code Cleanable} instance
>>> 221: * @throws IdentityException if the object is not an
>>
>> Nit - perhaps reword it as `if {@code obj} is not an ...`?
>
> Infact, should the newly added `@throws` specification state that the
> `IdentityException` is only thrown when value objects preview is enabled?
> Furthermore, should the newly introduced:
>
>
> Objects.requireIdentity(obj, "obj");
>
> instead be invoked only if `PreviewFeatures.isEnabled()`? I realize that deep
> within the call of `Objects.requireIdentity`, the preview enabled check does
> get exercised and this call returns normally when preview is disabled. But it
> might be more clear here at the call site to use a
> `PreviewFeatures.isEnabled()` before calling `Objects.requireIdentity()`.
Personal preference is to only have the isEnabled()-check within
requireIdentity itself, to avoid extraneous code throughout the codebase.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31123#discussion_r3460874335