JDK-8298502 : Console should be declared `sealed`
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2022-12-09
  • Updated: 2022-12-11
  • Resolved: 2022-12-11
Related Reports
CSR :  
Description
Summary
-------

Add `sealed` to the class signature of `java.io.Console` class declaration

Problem
-------

With the change to [JDK-8295803][1], `java.io.Console` class removed `final` classifier, thus it is possible to have an arbitrary subclass in the java.io package. Limiting this to known internal implementations improves platform integrity.

Specification
-------------

Change the declaration of `java.io.Console` class from
```
public class Console implements Flushable
```
to
```
public sealed class Console implements Flushable permits ClassA, ClassB, ...
```
*ClassA, ClassB, ...: package private classes in `java.io`. Names to be defined*


  [1]: https://bugs.openjdk.org/browse/JDK-8295803
Comments
From prior CSR review (https://bugs.openjdk.org/secure/EditComment!default.jspa?id=5087817&commentId=14538865), I support making this class sealed. Moving to Approved.
11-12-2022

There are no real compatibility issues as Console does not have an accessible constructor.
10-12-2022