Optimizing Errors Away
The HotSpot JIT compilers use a lot of sophisticated optimization techniques to speed up your Java code. Sometimes, these advanced optimizations are so aggressive that they may eliminate required checks by mistake and therefore suppress expected program errors.
In this talk, I'll briefly introduce Escape Analysis and Intrinsics, two commonly used HotSpot optimization techniques. I'll show how a combination of these two features can optimize away IndexOutOfBoundsExceptions in some corner cases where they are required by the standard and how I fixed this error in recent versions of the OpenJDK.