RFR: 8297271: AccessFlag.maskToAccessFlags should be specific to class file version [v4]

Roger Riggs rriggs at openjdk.org
Tue Apr 29 20:03:50 UTC 2025


On Tue, 29 Apr 2025 16:12:01 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Take the class file version to reject flags not yet defined, redefined, or obsoleted. The non-cffv version can return the preview flags when the current runtime is in preview.
>
> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:
> 
>  - Wording updates
>  - Merge branch 'feature/af-location-accessors' into feature/af-cffv-parse
>  - Missing since
>  - Fix javap causing strictfp tests to fail
>  - Further furnish docs
>  - Merge branch 'feature/af-location-accessors' into feature/af-cffv-parse
>  - Merge branch 'feature/af-location-accessors' into feature/af-cffv-parse
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/af-cffv-parse
>  - Redundant method
>  - 8297271: AccessFlag.maskToAccessFlags should be specific to class file version

src/java.base/share/classes/java/lang/reflect/AccessFlag.java line 401:

> 399:     public static Set<AccessFlag> maskToAccessFlags(int mask, Location location, ClassFileFormatVersion cffv) {
> 400:         var definition = findDefinition(location);
> 401:         int unmatchedMask = mask & (~location.flagsMask(cffv)); // implicit null check

Implicit null check is actually in `findDefinition`.
There's little harm is looking up the definition before checking for unmatched mask bits but it could be delayed and inlined as the argument to `new AccessFlagSet`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24760#discussion_r2067235737


More information about the core-libs-dev mailing list