This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: binary compatibility ABI


On Thursday, Sep 11, 2003, at 14:42 Pacific/Auckland, Bryce McKinlay wrote:

If you use a separate static field to check for initialization then you usually
have a memory read ordering issue between the flag read and the field read.
However if the value you test for initialization is used to compute the address
of the field itself, you still have a problem on Alpha, but on all other
architectures that we considered, the two reads appear to be ordered.

... class initialization can have other side effects besides setting the static fields of a class?

Actually, does the new Java memory model make any guarantees here? ie consider the following code:


class X
{
  static int a;

  void m()
  {
    System.out.println(Y.s);
    System.out.println(X.a);
  }
}

class Y
{
  static int s;
  static
  {
    Y.s = 55;
    X.a = 25;
  }
}

Presumably, the first println is guaranteed to print '55'? But is the second println guaranteed to print '25'?

Regards

Bryce.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]