RFR: 8338981: Access to private classes should be permitted inside the permits clause of the enclosing top-level class [v2]
Evemose
duke at openjdk.org
Mon Aug 26 22:07:33 UTC 2024
> Fix is quite hacky, but this is best solution that i came up with without making invasive changes in other parts of jdk. Basically, I check if current symbol is symbol for tree inside of permits clause i na following way:
>
> 1. env.tree is JCTree.JCClassDecl;
> 2. Trees in extends and implements clauses are already not null
> 3. There is at least one tree with null sym in permits clause (main indicator that permits clause resolution is in process)
>
> If all three of above are true, the requirment for symbol to be visible is to have sym.owner.outermostClass() == env.tree.sym.outermostClass()
>
> Not sure if this is a correct way to do it, hope more expirienced people out here could look into it more carefully.
>
> DEV NOTE: Will add test a bit later
>
> DEV NOTE 2: I`m not sure if non immidiate private memebrs should also be available in permit clause (like private static class A in private static class B that is in sealed class C should be available in permits clause of C as well). If not, condition on owner of symbol should be tightened a bit
Evemose has updated the pull request incrementally with one additional commit since the last revision:
allowed non-direct members to be permitted
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/20718/files
- new: https://git.openjdk.org/jdk/pull/20718/files/6df5e3f5..fd6e673d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=20718&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=20718&range=00-01
Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/20718.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20718/head:pull/20718
PR: https://git.openjdk.org/jdk/pull/20718
More information about the compiler-dev
mailing list