JDK-8245310 : Sealed Classes: Clarify treatment of `non-sealed` as a keyword
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-05-19
  • Updated: 2020-11-11
  • Resolved: 2020-10-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b19Fixed
Related Reports
Relates :  
Relates :  
Description
Currently the spec describes the string `non-sealed` as a reserved keyword. This means that according to the spec the following code should fail to compile:

int test(int non, int sealed) {
  return non-sealed;
}

However, this code compiles correctly (with the preview enabled). The spec should be updated with a notion of *contextual keyword* to allow `non-sealed` to be considered a keyword only in the places where needed.

See http://cr.openjdk.java.net/~gbierman/jep397/jep397-20201104/specs/contextual-keywords-jls.html