On Fri, 31 Jul 2026 15:52:01 GMT, Chen Liang <[email protected]> wrote:

>> Introduce an instance method, `isClassOrInterface`, to `java.lang.Class` and 
>> `java.lang.invoke.TypeDescriptor$OfField`.
>> 
>> `java.lang.constant.ClassDesc` comes with an `isClassOrInterface` method. It 
>> turns out that such a check is frequently needed in the use of `Class` 
>> objects, usually as `isArray() || isPrimitive()` or `!isArray() && 
>> !isPrimitive()`, with 14 occurrences in various reflective code.
>> 
>> In addition, `Class` can offer a more efficient implementation than two 
>> checks: it can perform a single bit pattern check to derive this result, 
>> making such an API more feasible.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chen Liang has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains eight additional commits since 
> the last revision:
> 
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 
> feature/class-is-class-or-interface-1
>  - More spec clarifications
>  - Wording review from Joe
>  - Update usage in Valhalla
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 
> feature/class-is-class-or-interface-1
>  - Simplify code
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 
> feature/class-is-class-or-interface-1
>  - Class.isClassOrInterface

Reviewed. Suggestions are inline.

_— qwen3.8-max-preview via Qwen Code /review_

src/java.base/share/classes/java/lang/Class.java line 929:

> 927:      * Classes and interfaces are {@linkplain ##referencetype reference 
> types}.
> 928:      * They are derived from {@code class} files and can declare fields 
> and
> 929:      * methods.

**[Suggestion]** The three `{@linkplain ##referencetype ...}` links (in 
`isInterface()`, `isArray()`, and `isClassOrInterface()` Javadoc) reference an 
anchor that does not exist in `Class.java`. The `<dfn>{@index "reference 
type"}s</dfn>` at line 889 creates a search index entry only — `{@index}` does 
not generate a linkable HTML `id`. No `id="referencetype"` attribute or 
markdown heading producing that anchor exists anywhere in the file (the only 
`id=` attributes are `hiddenClasses`, `implicitClasses`, and `nameFormat`). — 
Failure scenario: the javadoc tool emits warnings on every build of 
`java.base`, and the rendered API documentation has broken/unlinked "reference 
types" text in three method descriptions.

Consider adding an explicit anchor where the term is defined, e.g.:

 * collectively called <dfn>{@index "reference type"}s</dfn><a 
id="referencetype"></a>,

or replacing the `##referencetype` links with `{@linkplain #isPrimitive() 
reference types}`.

_— qwen3.8-max-preview via Qwen Code /review_

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

PR Review: https://git.openjdk.org/jdk/pull/32109#pullrequestreview-4833073386
PR Review Comment: https://git.openjdk.org/jdk/pull/32109#discussion_r3694142434

Reply via email to