Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

static fields problems in initialization

I have searched the JDK many times, but I can’t find where the out field is initialized

such as

public static final InputStream in = null;
public static final PrintStream out = null;
public static final PrintStream err = null;

So when are these static fields in the System class initialized?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In openjdk-11 java.lang.System on line 1968

setOut0(newPrintStream(fdOut, props.getProperty("sun.stdout.encoding")));

which is in private static void initPhase1() and that is documented to

Initialize the system class. Called after thread initialization.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading