On Sat, 22 Feb 2025 14:49:38 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:

>> Class.isInterface() can check modifier flags, Class.isArray() can check 
>> whether component mirror is non-null and Class.isPrimitive() needs a new 
>> final transient boolean in java.lang.Class that the JVM code initializes.
>> Tested with tier1-4 and performance tests.
>
> Coleen Phillimore has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Use modifiers field directly in isInterface.

A nice simplification.

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

> 239:     private Class(ClassLoader loader, Class<?> arrayComponentType, char 
> mods, ProtectionDomain pd, boolean isPrim) {
> 240:         // Initialize final field for classLoader.  The initialization 
> value of non-null
> 241:         // prevents future JIT optimizations from assuming this final 
> field is null.

To add a bit more depth to this comment, I'd add.

"The following assignments are done directly by the VM without calling this 
constructor."
Or something to that effect.

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

Marked as reviewed by rriggs (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23572#pullrequestreview-2638174546
PR Review Comment: https://git.openjdk.org/jdk/pull/23572#discussion_r1968254793

Reply via email to