RFR: 8362885: A more formal way to mark javac's Flags that belong to a specific Symbol type only [v5]
Jan Lahoda
jlahoda at openjdk.org
Mon Aug 11 09:57:03 UTC 2025
> This PR proposes to improve handling of javac's `Flags` in two ways:
> - for each flag, there's now an informational annotation specifying what is the target Symbol type. Only targets right now are `TypeSymbol`s, `MethodSymbol`s and `VarSymbol`s. If we ran out of flags for `TypeSymbol`s, we could split those to module/package/class/type variable, but it does not seem to be quite necessary yet. There's an auxiliary special `BLOCK`, which is for `JCBlock`.
> - the manually handled `Flags.Flag` enum is replaced with autogenerated `FlagsEnum`
>
> This is inspired by:
> https://github.com/openjdk/jdk/pull/26181#pullrequestreview-2997428662
>
> There may be some better to handle `Flags` eventually, but this hopefully improves the current situation at least somewhat, by providing more formal way to say the flags' target, and restricting the need to read comments and search for free flags.
>
> As a side-effect of this annotation, the `test/langtools/tools/javac/flags/FlagsTest.java` now also prints which flags are free, for each Symbol type.
>
> (I will remove the `build` label for now, until discussion on javac level is done, and will re-add it if we decide the goal to autogenerate the FlagsEnum makes sense.)
Jan Lahoda has updated the pull request incrementally with three additional commits since the last revision:
- Merge remote-tracking branch 'origin/JDK-8362885' into JDK-8362885
- Using EnumMap, as suggested.
- Removing unnecessary delimited, as suggested.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/26452/files
- new: https://git.openjdk.org/jdk/pull/26452/files/019d0061..2095f574
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=26452&range=04
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=26452&range=03-04
Stats: 4 lines in 2 files changed: 1 ins; 2 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/26452.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26452/head:pull/26452
PR: https://git.openjdk.org/jdk/pull/26452
More information about the compiler-dev
mailing list