RFR: 8338981: Access to private classes should be permitted inside the permits clause of the enclosing top-level class [v7]

Vicente Romero vromero at openjdk.org
Wed Oct 2 17:25:39 UTC 2024


On Sat, 28 Sep 2024 22:31:14 GMT, Evemose <duke at openjdk.org> wrote:

>> Fix involves adding new flag to after context that indicates that currently resolved symbol is in permits clause
>
> Evemose has updated the pull request incrementally with one additional commit since the last revision:
> 
>   remove trailing line

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java line 97:

> 95:     /** Are we attributing a permits clause?
> 96:      */
> 97:     boolean isPermitsClause = false;

you need to copy the value of this field in the ::dup method as it is done for other fields in this class

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java line 982:

> 980:                 ListBuffer<Symbol> permittedSubtypeSymbols = new ListBuffer<>();
> 981:                 List<JCExpression> permittedTrees = tree.permitting;
> 982:                 baseEnv.info.isPermitsClause = true;

usually we save the previous value of the field before setting a new value, then inside a `try` we invoke the code that should be aware of the field and then in the `finally` we restore the previous value of the field, see for example how we do for field `AttrContext::ctorPrologue`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20718#discussion_r1784917292
PR Review Comment: https://git.openjdk.org/jdk/pull/20718#discussion_r1784921558


More information about the compiler-dev mailing list