Originally posted by Stan James:
I think you'll find they are not final.
Ah. This is one of the hairy little corners of the
Java API. They
are final -- go check! The setOut(), setIn(), setErr() methods delegate to native methods, which aren't bound by ordinary mortal Java rules. Final variables which can change -- in the API! Aaaak!
A better implementation seems obvious to me: PrintStream isn't final, so they could have just used a package-private PrintStream class which allowed the underlying OutputStream to be changed, and then have setOut() merely twiddle that internal setting, without this crazy final variable modification.
Never did figure out their rationale there.