RFR: 8330998: System.console() writes to stderr when stdout is redirected [v2]

Archie Cobbs acobbs at openjdk.org
Mon Apr 29 20:24:06 UTC 2024


On Mon, 29 Apr 2024 19:52:17 GMT, Bernd <duke at openjdk.org> wrote:

> Of course the question is if it should write to stderr or /dev/tty like mechanism..

I was wondering the same thing. My understanding of the definition of "console" is a bidirectional byte channel with a keyboard & screen on the other end. It has no concept of stdout vs. stderr. It just has a display (or in the old days, a printer).

The function of a "shell" is to intermediate between one or more executing programs and the console. It figures out how & when to actually display on the console any stuff written to stdout and/or stderr by one of the programs it has launched.

A program can also access its console (if any) directly by opening /dev/tty or whatever, thereby bypassing the shell.

So I would think writing to something called "System.console()" from Java (which is a program) would have nothing to do with Java's stderr or stdout, except for a possible downstream interleaving with what the shell may also be writing to the console at the same time.

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

PR Comment: https://git.openjdk.org/jdk/pull/18996#issuecomment-2083593864


More information about the core-libs-dev mailing list