On Fri, 31 Jul 2026 02:47:06 GMT, Jaikiran Pai <[email protected]> wrote:

>> 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 five additional 
>> commits since the last revision:
>> 
>>  - 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
>
> Hello Chen, at the very least, the name of this new method will need 
> additional thoughts. The immediate thought that comes to mind when seeing 
> this method name is how it would behave with `Class` instance which represent 
> (for example) `enum` or `record`. I think if the goal is to have a method 
> which guarantees that the type represented by the `Class` instance is not an 
> array or a primitive, then maybe that detail should be in the method name in 
> some form. Or maybe a much more formal term (I haven't looked up if there is 
> any) for such types.
> 
> As for performance motivations for this new API, I don't think that should be 
> a consideration for this proposal.
> 
> Finally, it's not clear that the current usage patterns like `cls.isArray() 
> || cls.isPrimitive()` is a (big enough) hassle that it deserves a new Java SE 
> API.

> Hello @jaikiran, this method is named because of the name chosen by 
> `ClassDesc::isClassOrInterface`.
> 
> "Class and interface" are significant enough for special recognition given 
> the fact that they are all derived from `class` files and therefore can 
> declare methods and fields in addition to inheriting them, instead of the 
> status of "not an array or a primitive".

Hands may be tied here, but two observations:

1: Asking a class whether it "is a class or interface" feels a bit awkward and 
from a high level view it defies basic logic. A class "is a" class, so without 
reading into the fine print, this method could be expected to always return 
true.
2: The outlier here seems to be the "array or primitive" case. This case seems 
to be immediately recognizable for anyone glazing over the API surface.

Was `!clazz.isArrayOrPrimitive()` considered as an alternative?

Or is the underlyning issue here that "class" is an overloaded term in this 
context and we just need to lean into the fact that a `Class` is not (always) 
"a class"?

Maybe we're missing a term for a `Class` which is in fact a class?

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

PR Comment: https://git.openjdk.org/jdk/pull/32109#issuecomment-6309944981

Reply via email to