I am checking some statements from JMM and I wrote a JCS test like this:
@JCStressTest
@State
@Outcome(expect = ACCEPTABLE, desc = "ACCEPTABLE")
public class ConcurrencyTest {
private final int a = 1;
private final int b = 2;
public ConcurrencyTest instance;
@Actor
public void actor1() {
instance = new ConcurrencyTest();
}
@Actor
public void actor2(II_Result result) {
ConcurrencyTest c = instance;
if (c != null) {
result.r1 = c.a;
result.r2 = c.b;
}
}
}
After running this test, I see the following results:
(0, 0) (1, 2)
Although the JMM explicitly states that the result (0, 0) is forbidden, why is this happening?