System.out.println in java - Is out initialized in a native method? -
i wanted know if out
variable in system.out.println()
initialized in static block of system
class. out
field declared final static variable, equals null (public final static printstream out = null;
) . since out pointing null, assume being pointed printstream
object somewhere. can't see code except native method called registernatives()
. being pointed in native method? why being done way (any performance advantage)? also, documentation out
variable in system
says:
the "standard" output stream. stream open , ready accept output data. typically stream corresponds display output or output destination specified host environment or user."
thanks.
the out registration flow
java virtual machine (jvm)
invokes
private static void initializesystemclass()
@ line-1155
the function call
setout0(newprintstream(fdout, props.getproperty("sun.stdout.encoding")))
@ line-1192
invokes
actual native method
defined
private static native void setout0(printstream out);
@ line-258
;
then
setout0
initializesout
class memeber.
Comments
Post a Comment