mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8332029: Provide access to initial value of stderr via JavaLangAccess
Reviewed-by: jpai, bpb, mcimadamore
This commit is contained in:
parent
f9a1d3381b
commit
32c7681cf3
3 changed files with 25 additions and 10 deletions
|
@ -191,8 +191,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;
|
||||
// Initial values of System.in and System.err, set in initPhase1().
|
||||
private static @Stable InputStream initialIn;
|
||||
private static @Stable PrintStream initialErr;
|
||||
|
||||
// indicates if a security manager is possible
|
||||
private static final int NEVER = 1;
|
||||
|
@ -355,9 +356,6 @@ public final class System {
|
|||
= Collections.synchronizedMap(new WeakHashMap<>());
|
||||
}
|
||||
|
||||
// Remember initial System.err. setSecurityManager() warning goes here
|
||||
private static volatile @Stable PrintStream initialErrStream;
|
||||
|
||||
private static URL codeSource(Class<?> clazz) {
|
||||
PrivilegedAction<ProtectionDomain> pa = clazz::getProtectionDomain;
|
||||
@SuppressWarnings("removal")
|
||||
|
@ -417,7 +415,7 @@ public final class System {
|
|||
} else {
|
||||
source = callerClass.getName() + " (" + url + ")";
|
||||
}
|
||||
initialErrStream.printf("""
|
||||
initialErr.printf("""
|
||||
WARNING: A terminally deprecated method in java.lang.System has been called
|
||||
WARNING: System::setSecurityManager has been called by %s
|
||||
WARNING: Please consider reporting this to the maintainers of %s
|
||||
|
@ -2200,7 +2198,8 @@ public final class System {
|
|||
// thus they are equivalent to Console.charset(), otherwise the encodings
|
||||
// of those properties default to native.encoding
|
||||
setOut0(newPrintStream(fdOut, props.getProperty("stdout.encoding")));
|
||||
setErr0(newPrintStream(fdErr, props.getProperty("stderr.encoding")));
|
||||
initialErr = newPrintStream(fdErr, props.getProperty("stderr.encoding"));
|
||||
setErr0(initialErr);
|
||||
|
||||
// Setup Java signal handlers for HUP, TERM, and INT (where available).
|
||||
Terminator.setup();
|
||||
|
@ -2406,8 +2405,6 @@ public final class System {
|
|||
notSupportedJnuEncoding);
|
||||
}
|
||||
|
||||
initialErrStream = System.err;
|
||||
|
||||
// initializing the system class loader
|
||||
VM.initLevel(3);
|
||||
|
||||
|
@ -2598,6 +2595,10 @@ public final class System {
|
|||
return initialIn;
|
||||
}
|
||||
|
||||
public PrintStream initialSystemErr() {
|
||||
return initialErr;
|
||||
}
|
||||
|
||||
public void setCause(Throwable t, Throwable cause) {
|
||||
t.setCause(cause);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue