[lworld] RFR: Add Class.isIdentity

Mandy Chung mchung at openjdk.java.net
Tue May 31 22:07:48 UTC 2022


On Tue, 31 May 2022 18:22:33 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Add j.l.Class.isIdentity() as a complement to Class.isValue() and Class.isPrimitiveClass.
> 
> Class.getModifiers() is updated to remove VM was suppressing the ACC_IDENTITY bit (previously known as ACC_SUPER).
> 
> Updated Class.toString() to reflect the addition of ACC_IDENTITY.
> For regular identity classes and interfaces, there is no change to toString.
> 
> Removed the obsolete test for ACC_SUPER
> 
> This PR may need to wait for corresponding VM changes.

src/hotspot/share/oops/instanceKlass.cpp line 3398:

> 3396:     }
> 3397:   }
> 3398:   // Do not strip ACC_SUPER, its ACC_IDENTITY now

I think this should apply only if `EnableValhalla` (or `--enable-preview` is set).

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

> 207:     private static final int VALUE_CLASS     = 0x00000040;
> 208:     private static final int PERMITS_VALUE   = 0x00000100;
> 209:     private static final int PRIMITIVE_CLASS = 0x00000800;  // Not in JVMS spec

It's defined in http://cr.openjdk.java.net/~dlsmith/jep401/jep401-20211220/specs/primitive-classes-jvms.html#jvms-4.1

test/jdk/valhalla/valuetypes/StaticFactoryTest.java line 44:

> 42: import static org.testng.Assert.*;
> 43: 
> 44: public final identity class StaticFactoryTest {

Is this changed needed?

test/jdk/valhalla/valuetypes/StaticFactoryTest.java line 88:

> 86:                 new Object[] { SimpleIdentity.class, true, false, false },
> 87:                 new Object[] { SimplePrimitive.class, false, true, true },
> 88:                 new Object[] { SimpleValue.class, false, true, false },

It'd be good to add  a regular class and interface (no `identity` modifier) and other `interface` test cases as well.

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

PR: https://git.openjdk.java.net/valhalla/pull/700



More information about the valhalla-dev mailing list