RFR: 8349860: Make Class.isArray(), Class.isInterface() and Class.isPrimitive() non-native

Dean Long dlong at openjdk.org
Wed Feb 19 02:56:57 UTC 2025


On Tue, 11 Feb 2025 20:56:39 GMT, Coleen Phillimore <coleenp at 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.

src/hotspot/share/classfile/javaClasses.inline.hpp line 301:

> 299: #ifdef ASSERT
> 300:   // The heapwalker walks through Classes that have had their Klass pointers removed, so can't assert this.
> 301:   // assert(is_primitive == java_class->bool_field(_is_primitive_offset), "must match what we told Java");

I don't understand this comment about the heapwalker.  It sounds like we could have `is_primitive` set to true incorrectly.  If so, what prevents the asserts below from failing?  And why not use the value from _is_primitive_offset instead?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23572#discussion_r1960876174


More information about the core-libs-dev mailing list