[lworld] RFR: 8376430: [lworld] Remove Modifier.IDENTITY
Joe Darcy
darcy at openjdk.org
Tue Jan 27 21:10:47 UTC 2026
On Tue, 27 Jan 2026 05:09:10 GMT, Chen Liang <liach at openjdk.org> wrote:
> `java.lang.reflect.Modifier` represents Java language modifiers. Since a previous iteration of JEP 401, the "identity" source modifier is removed, and only "value" source modifier exists. As a result, "identity" is no longer qualified to be present in `Modifier`. We should migrate all its uses to `ClassFile.ACC_IDENTITY` or `AccessFlag.IDENTITY` (which already correctly identifies itself not as a source modifier).
>
> This also avoids the headache of `Modifier.toString` clashing over `SYNCHRONIZED` versus `IDENTITY`.
At a high-level, I concur that removing IDENTITY from Modifiers is the correct direction. The toString() methods of classes, or other affected constructs, can be updated to still print out source-level information even when the language and VM model a concept differently.
src/java.base/share/classes/java/lang/Class.java line 644:
> 642: * For all other {@code Class} objects, this method returns {@code true} if either
> 643: * preview features are disabled or {@linkplain ClassFile#ACC_IDENTITY} is set in the
> 644: * {@linkplain #getModifiers() class modifiers}.
Change "class modifiers" to "access flags" (or equivalent) or line 644.
src/java.base/share/classes/java/lang/Class.java line 666:
> 664: * For all other {@code Class} objects, this method returns {@code true} only if
> 665: * preview features are enabled and {@linkplain ClassFile#ACC_IDENTITY} is not set in the
> 666: * {@linkplain #getModifiers() class modifiers}.
Same comment as on line 644.
-------------
PR Comment: https://git.openjdk.org/valhalla/pull/1980#issuecomment-3807541500
PR Review Comment: https://git.openjdk.org/valhalla/pull/1980#discussion_r2733824331
PR Review Comment: https://git.openjdk.org/valhalla/pull/1980#discussion_r2733825774
More information about the valhalla-dev
mailing list