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

Evemose duke at openjdk.org
Thu Sep 12 21:55:59 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. Tree symbols 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 two additional commits since the last revision:

 - add attr context flag
 - test

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20718/files
  - new: https://git.openjdk.org/jdk/pull/20718/files/fd6e673d..7d05c664

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20718&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20718&range=01-02

  Stats: 69 lines in 4 files changed: 53 ins; 15 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