[sealed-classes] Spec for next version of Sealed Classes
Gavin Bierman
gavin.bierman at oracle.com
Fri Oct 23 15:16:20 UTC 2020
Dear all:
Drafts of the specs for the Sealed Classes feature that we plan to preview for
a second time in JDK 16 are now available:
http://cr.openjdk.java.net/~gbierman/8246775/latest/
[NB: The URL will change once we have a JEP number, and will be announced.]
The changes are the same as those in the first preview that was released in Java
SE 15, except for minor editorial changes and the following:
- Clarification the use of context when applying the lexical grammar,
particularly in the identification of contextual keywords (formerly described
as "restricted identifiers" and "restricted keywords"). This is detailed in a
companion document entitled “Contextual Keywords". The keywords `sealed`,
`non-sealed`, and `permits` are now defined as new instances of contextual
keywords (3.9).
- This spec now assumes that the changes detailed in companion documents
entitled "Consistent Class and Interface Terminology” and "Local and Nested
Static Declarations" have been applied (these are being introduced as part of
the Records JEP). In particular, this means that Java SE 16 will support
static declarations in two new positions:
1. Local, implicitly-static interfaces and enum classes
2. Static members of inner classes
This requires asserting that local interfaces are not permitted to be
`sealed`. (14.3)
- To enhance narrowing reference conversion to allow for stricter checking of
cast conversions with respect to sealed type hierarchies (5.1.6.1).
- Local classes are not considered when determining implicitly declared
permitted direct subclasses of a `sealed` class or `sealed` interface
(8.1.6, 9.1.4).
Comments welcome!
Gavin
More information about the amber-spec-experts
mailing list