At 1:16 PM -0700 10/26/99, Joseph Bowbeer wrote:
>Speaking of System's setErr and setOut methods, I hear that a recent JDC
>(developer.java.sun.com) mailing contains sample code.
>
>I can try to track it down if anyone's interested, but I think it boils down
>to something like the following:
>
> PrintStream out = System.out;
> PrintStream log /* = output log */;
> System.out.println("before logging");
> System.setOut(log);
> System.out.println("logging");
> System.setOut(out);
> System.out.println("after logging");
>
>Is there anything in the old JMM or new JMM to prevent the compiler from
>emitting code that reads System.out only once?
>
The old JMM didn't assign any special semantics to final variables,
so System.out had to be reloaded each time.
Under the new semantics, if System.out is treated as a writeProtected
field, then it will also have to be reloaded each time.
Bill
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:21 EDT