Re: JavaMemoryModel: Why not delegate, instead of see it as special case?

From: Sylvia Else (
Date: Sat Oct 04 2003 - 18:15:55 EDT

At 09:36 PM 3/10/2003 +0200, Doron Rajwan wrote:

>I do not understand why, out, and err won't be replaced with

A not improbable scenario is that a program saves the initial content of
System.err, and then calls System.setErr() to redirect error messages to
somewhere more appropriate. The original contents would be used for severe
error conditions, such as not being able to write to the redirected stream.

This mechanism would break under your proposal.

Another scenario that breaks is an attempt at temporary redirection, by
storing the content of System.out, and restoring it later.

One may wonder at the thinking of the person who perpetrated the
System.setOut, Err, In() mechanism, but we do seem to be stuck with it.


>What I mean is:
>1. Define a class that extends PrintStream and delegate to another
>2. System.out will be final instance of this class, w/o any magic involved.
>3. When someone wants to change the output, they can use a method to
>change the delegation. This method can be public method, and the Security
>check will be inside it.
>4. The native magic can be removed.
>I cannot see how this change will break anything, except, maybe, when
>someone sync(System.out) in order to print few lines together. Maybe this
>can be solved too, using some tricks.
>My question is: have you considered other options, except declaring these
>3 variables as special case?

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:51 EDT