RFR: 8293897: Synthetic final modifier is part of the AST for a try-with-resource resource
Jan Lahoda
jlahoda at openjdk.org
Mon Sep 19 18:37:20 UTC 2022
The resources in try-with-resource are implicitly final (unless they are marked as final in the source code). But, in javac, the `FINAL` modifier is part of the modifiers on the AST, which is in contrary to the usual direction of having the AST closely model the source code.
The proposal here is to not add the synthetic `FINAL` modifier to the AST, but add it to the given `VarSymbol`. The positions of the `ModifiersTree` are also tweaked, so that for a synthetic tree, the positions are `NOPOS`.
-------------
Commit messages:
- 8293897: Final modifier auto inserted as part of try with resources statement
Changes: https://git.openjdk.org/jdk/pull/10348/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10348&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8293897
Stats: 71 lines in 3 files changed: 67 ins; 1 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/10348.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10348/head:pull/10348
PR: https://git.openjdk.org/jdk/pull/10348
More information about the compiler-dev
mailing list