In section 17.4.5 "Happens-before Order" of Java Language Specification, a trace is examined for the notion of happens-before consistency.
The trace is shown in the figure in which $A$ and $B$ are shared variables with initially $A = B = 0$.
An execution order of the trace is as follows.
In this execution, the reads see writes that occur later in the execution order. The document says that it is happens-before consistent. I am quite confused about this. In my opinion, this execution order does not even satisfy program order. Why is it happens-before consistent?