Re: JavaMemoryModel: Serialization and final fields

From: Bill Pugh (pugh@cs.umd.edu)
Date: Wed Aug 25 1999 - 10:38:15 EDT


At 3:18 AM -0700 8/25/99, Joshua Bloch wrote:
>P.S. In case you're not already physically ill, note that the
>methods System.setErr, setIn and setOut are specified to set the
>values of the fields System.err, in and out, all of which are
>specified to be final. Yeccccch

Yecchh is right. It probably isn't feasible to fix this, by either
deprecating setOut et al or by replacing System.out with
System.getOutput(). This creates problems with the idea that final
variables never have to be reloaded across memory barriers: you would
never need see any changes to those variables.

So, do we:

   * Say that System.in, System.out and System.err are special: they
have the semantics of non-final variables, except that non-native,
non-System code cannot change them. However, in general it is an
error for native code to change final variables.

   * Say that in general, it is acceptable to have native code change
final fields.

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:18 EDT