8295803: Console should be usable in jshell and other environments

Reviewed-by: jlaskey, alanb
This commit is contained in:
Naoto Sato 2022-12-07 20:49:29 +00:00
parent 5d4c71c8bd
commit 8a9911ef17
17 changed files with 673 additions and 23 deletions

View file

@ -189,6 +189,9 @@ public final class System {
*/
public static final PrintStream err = null;
// Holder for the initial value of `in`, set within `initPhase1()`.
private static InputStream initialIn;
// indicates if a security manager is possible
private static final int NEVER = 1;
private static final int MAYBE = 2;
@ -2174,7 +2177,8 @@ public final class System {
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
setIn0(new BufferedInputStream(fdIn));
initialIn = new BufferedInputStream(fdIn);
setIn0(initialIn);
// stdout/err.encoding are set when the VM is associated with the terminal,
// thus they are equivalent to Console.charset(), otherwise the encodings
// of those properties default to native.encoding
@ -2485,6 +2489,10 @@ public final class System {
return StringCoding.implEncodeAsciiArray(src, srcOff, dst, dstOff, len);
}
public InputStream initialSystemIn() {
return initialIn;
}
public void setCause(Throwable t, Throwable cause) {
t.setCause(cause);
}