1 class Example1 { 2 private Object _cache; 3 public void test(boolean cond) { 4 Object x = new Object(); 5 6 if (cond) { 7 _cache = x; 8 } 9 } 10 11 public Object test2(boolean cond) { 12 Object x = new Object(); 13 14 if (cond) { 15 _cache = x; 16 } 17 18 return cond ? null: x; 19 } 20 21 public static void main(String[] args) { 22 Example1 kase = new Example1(); 23 24 for (int i = 0; i < 1_000_000; ++i) { 25 kase.test(0 == (i& 0xf)); 26 kase.test2(0 == (i& 0xf)); 27 } 28 } 29 }