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

Vicente Romero vromero at openjdk.org
Thu Oct 24 19:52:13 UTC 2024


On Fri, 18 Oct 2024 21:48:09 GMT, Evemose <duke at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java line 475:
>> 
>>> 473:             }
>>> 474:         }
>>> 475:         return false;
>> 
>> shouldn't we return true here?
>
> No, method name is privateMemberInPermitsClause if allowed, and return is:
> 1. If condition in if is met, then return whether feature is enabled or not (value of field allowPrivateMembersInPermitsClause)
> 2. If condition is not met, then this is NOT privateMemberInPermitsClause, so return false

what about:

private boolean privateMemberInPermitsClauseIfAllowed(Env<AttrContext> env, Symbol sym) {
    return allowPrivateMembersInPermitsClause &&
           env.info.isPermitsClause &&
           ((JCClassDecl) env.tree).sym.outermostClass() == sym.owner.outermostClass();
}

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

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


More information about the compiler-dev mailing list