-
Enhancement
-
Resolution: Fixed
-
P4
-
18
The following declaration is illegal because the member class X.Y cannot be accessed in the `permits` clause:
sealed class X permits X.Y {
private static final class Y extends X {}
}
(Note that this issue is about accessibility, not scope. Scope involves simple names, such as `Y`, but the `permits` clause above uses a qualified name, `X.Y`.)
The illegality of accessing `X.Y` is inconsistent with the legality of the following equivalent code, where the `permits` clause is implicitly declared:
sealed class X {
private static final class Y extends X {}
}
The text in 6.6.1 concerning access of a private member should be clarified as follows:
-----
Otherwise, the member or constructor is declared private. Access is permitted only when one of the following is true:
- Access occurs from within the body of the top level class or interface that encloses the declaration of the member or constructor.
- Access occurs in the `permits` clause of the top level class or interface that encloses the declaration of the member.
- Access occurs in the record component list of the top level record class that encloses the declaration of the member.
-----
sealed class X permits X.Y {
private static final class Y extends X {}
}
(Note that this issue is about accessibility, not scope. Scope involves simple names, such as `Y`, but the `permits` clause above uses a qualified name, `X.Y`.)
The illegality of accessing `X.Y` is inconsistent with the legality of the following equivalent code, where the `permits` clause is implicitly declared:
sealed class X {
private static final class Y extends X {}
}
The text in 6.6.1 concerning access of a private member should be clarified as follows:
-----
Otherwise, the member or constructor is declared private. Access is permitted only when one of the following is true:
- Access occurs from within the body of the top level class or interface that encloses the declaration of the member or constructor.
- Access occurs in the `permits` clause of the top level class or interface that encloses the declaration of the member.
- Access occurs in the record component list of the top level record class that encloses the declaration of the member.
-----
- relates to
-
JDK-8338981 Access to private classes should be permitted inside the permits clause of the enclosing top-level class
-
- Resolved
-
-
JDK-8282913 8.10.1: Clarify scope of record components
-
- Resolved
-
-
JDK-8282916 6.3: Clarify that a nested declaration's scope includes component list of enclosing record class
-
- Resolved
-