[lworld] RFR: 8363846: [lworld] Make Class.isIdentityClass() non-native [v3]

Chen Liang liach at openjdk.org
Wed Jul 23 16:09:16 UTC 2025


On Wed, 23 Jul 2025 15:54:54 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> This moves isIdentityClass() implementation to Class.java, and checks within the JVM that is_identity_class() doesn't check the access flags for an ArrayKlass, since AccessFlags aren't initialized in ArrayKlasses.  The AccessFlags should be moved from Klass.hpp to InstanceKlass.cpp in mainline but that's a more complicated change and has several pieces.
>> Added a test.
>> Tested with tier1 locally.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix test to use junit and test without preview mode.

test/jdk/valhalla/valuetypes/IsIdentityClassTest.java line 52:

> 50: 
> 51:     private static void assertFalseIfPreview(boolean condition, String msg) {
> 52:         if (PreviewFeatures.isEnabled()) {

We can use `assertEquals(!PreviewFeatures.isEnabled(), msg)`

test/jdk/valhalla/valuetypes/IsIdentityClassTest.java line 63:

> 61:         RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
> 62:         List<String> arguments = runtimeMxBean.getInputArguments();
> 63:         boolean UseArrayFlattening = !arguments.contains("-XX:-UseArrayFlattening");

Optional comments:

I wonder if it's more usually to obtain flags with serviceability, or explicitly pass -D properties...

Also for these global states, it's better to capture them with a `@Setup static void setup()` method and store in static fields, especially if multiple tests use these states.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1514#discussion_r2226056359
PR Review Comment: https://git.openjdk.org/valhalla/pull/1514#discussion_r2226054918


More information about the valhalla-dev mailing list