Integrated: 8293897: Synthetic final modifier is part of the AST for a try-with-resource resource

Jan Lahoda jlahoda at openjdk.org
Wed Sep 21 12:33:50 UTC 2022


On Mon, 19 Sep 2022 18:28:32 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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`.

This pull request has now been integrated.

Changeset: 95ec2eac
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/95ec2eaca3845bc971d3e711e5f61052c2951fa8
Stats:     88 lines in 3 files changed: 84 ins; 1 del; 3 mod

8293897: Synthetic final modifier is part of the AST for a try-with-resource resource

Reviewed-by: sundar

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

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


More information about the compiler-dev mailing list