Duplicate :
|
The following test case results in wrong data (variable var_check) when running with enabled escape analysis. > jdk7b43/bin/java -server -Xcomp -XX:CompileOnly=EATester -XX:+DoEscapeAnalysis EATester EATester.var_check = 0 (expected 1) the results are ok when running with disabled escape analysis: > jdk7b43/bin/java -server -Xcomp -XX:CompileOnly=EATester -XX:-DoEscapeAnalysis EATester EATester.var_check = 1 (expected 1) ========= EATester.java ========= class EATester_Class_1 { static String var_1; static void badFunc(int size) { try { for (int i = 0; i < 1; (new byte[size-i])[0] = 0, i++) {} } catch (Exception e) { // don't comment it out, it will lead to correct results ;) //System.out.println("Got exception: " + e); } } } public class EATester { static String var_1_copy = EATester_Class_1.var_1; static byte var_check; public static void main(String[] args) { var_check = 1; EATester_Class_1.badFunc(-1); System.out.println("EATester.var_check = " + EATester.var_check + " (expected 1)\n"); } } =================================