RFR: 8347471: Provide valid flags and mask in AccessFlag.Location [v9]
Roger Riggs
rriggs at openjdk.org
Mon Apr 28 21:57:46 UTC 2025
On Mon, 28 Apr 2025 20:20:28 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Some AccessFlag parsing methods throw IAE because a flag mask is not valid in a location. However, there is no easy way to check what flag mask bits or what flags are valid for a location. We need such APIs to check, specific to each class file format version.
>>
>> Also in the investigation, it's noted that `ACC_SYNTHETIC` is incorrectly represented - it is available since release 5.0 instead of release 7. This bug is fixed together for implementation simplicity.
>>
>> The new methods are all in `AccessFlag.Location`:
>> - `Set<AccessFlag> flags()`
>> - `int flagsMask()`
>> - `Set<AccessFlag> flags(ClassFileFormatVersion)`
>> - `int flagsMask(ClassFileFormatVersion)`
>>
>> Also there is some simplification to `AccessFlag` itself to remove the anonymous classes, which should be more startup-friendly.
>>
>> Testing: Tier 1-3
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>
> Wording updates, thanks Roger
The "kinds of constructs" phrase can be replaced by "Locations" and improve readability.
In AccessFlag.java: 326, there is a pre-existing "integer" that could be removed to be consistent with the other mentions of the mask.
src/java.base/share/classes/java/lang/reflect/AccessFlag.java line 342:
> 340: /**
> 341: * {@return kinds of constructs this flag can be applied to in the
> 342: * current class file format version}
Suggestion:
* {@return Locations this flag can be applied to in the
* current class file format version}
src/java.base/share/classes/java/lang/reflect/AccessFlag.java line 352:
> 350:
> 351: /**
> 352: * {@return kinds of constructs this flag can be applied to in the
Suggestion:
* {@return Locations this flag can be applied to in the
-------------
PR Review: https://git.openjdk.org/jdk/pull/23095#pullrequestreview-2801073592
PR Review Comment: https://git.openjdk.org/jdk/pull/23095#discussion_r2064846060
PR Review Comment: https://git.openjdk.org/jdk/pull/23095#discussion_r2064847670
More information about the core-libs-dev
mailing list