RFR: 8337219: AccessFlags factories do not require necessary arguments

Chen Liang liach at openjdk.org
Thu Jul 25 23:16:42 UTC 2024


Removes 6 `AccessFlags` factories that do not take class-file versions as its arguments.

`AccessFlags` is a wrapper around a bit mask to support modifier streaming in ClassFile API. It additionally supports advanced validation based on location.

However, as class file versions evolve, we may also need a class file version argument to ensure that the flags are correctly constructed. For example, a pre-valhalla class modifier without `ACC_SUPER` should not be interpreted as a value class. The current factories cannot find good default class file versions, and if they always assume latest, they will fail in this scenario.

As a result, we should remove these 6 factories; note that users can still set the flags via `XxxBuilder::withFlags` with either `int` or `AccessFlag...` flags. In contrast, these builder APIs can fetch the previously-passed class file versions, and correctly validate or interpret these flags. Same story goes for parsing, which can also construct the right flags with available information.

This enables us to add methods to interpret the logical flags with version-specific information. If there's need, we can always add a new `AccessFlags.of(int, AccessFlag.Location, ClassFileFormatVersion)` factory, given the flexibility from this removal.

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

Commit messages:
 - 8337219: AccessFlags factories do not require necessary arguments

Changes: https://git.openjdk.org/jdk/pull/20341/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20341&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8337219
  Stats: 212 lines in 21 files changed: 71 ins; 80 del; 61 mod
  Patch: https://git.openjdk.org/jdk/pull/20341.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20341/head:pull/20341

PR: https://git.openjdk.org/jdk/pull/20341


More information about the compiler-dev mailing list