A post on hotspot-compiler-dev shows a problem with volatile field loads in C1:
http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2012-May/007698.html
The failing test case is:
public class Test {
volatile static private int a;
static private int b;
public static void main(String [] args) throws Exception {
for (int i = 0; i < 100; i++) {
new Thread() {
@Override
public void run() {
int tt = b; // makes the jvm cache the value of b
while (a==0) {
}
if (b == 0) {
System.out.println("error");
}
}
}.start();
}
b = 1;
a = 1;
}
}
To hit the bug run:
$ java -client Test