RFR: 8298416: Console should be declared `sealed` [v2]

Jaikiran Pai jpai at openjdk.org
Wed Dec 14 02:21:34 UTC 2022


On Tue, 13 Dec 2022 18:42:53 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> src/java.base/share/classes/java/io/Console.java line 108:
>> 
>>> 106:     public PrintWriter writer() {
>>> 107:         throw new UnsupportedOperationException(
>>> 108:                 "Console class itself does not provide implementation");
>> 
>> Hello Naoto, should we perhaps then mark this method (and thus the class too) as `abstract` and leave the sub-classes to provide this method's implementation? Same with the other methods where we now throw `UnsupportedOperationException`.
>
> Thanks for the review, Jai. You're right that making it `abstract` would eliminate implementations in `Console` class, but I was hesitant to do so, as it is a spec change that would suggest readers to think that `Console` is generally pluggable (which is not).

That's reasonable and I think the current non-abstract form is fine then.

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

PR: https://git.openjdk.org/jdk/pull/11615


More information about the core-libs-dev mailing list