Either the statement contains a volatile read, or it does not contain a volatile read. There can be no ambiguity here, since volatile reading is very important for programming semantics.
If javac can be trusted, we can conclude that the statement does not include a volatile reading of number . The value of the assignment expression x=y is actually just the value of y (after conversions).
It can also be deduced that
System.out.println(number=1);
does not include reading number
String s; (s="hello").length();
does not include reading s
x_1=x_2=...x_n=v
does not include reading x_n, x_n-1, ... ; instead, the value of v assigned directly to x_i (after the necessary transformations through the types x_n, ... x_i
irreputable Oct 12 '12 at 17:05 2012-10-12 17:05
source share