title: Hack the JVM to avoid unnecessary bounds checks and casts
body: <p>There are some languages that support a sufficiently powerful type system that they can prove at compile time that the code does not address an array outside its bounds. My question is that if we were to compile such a language to the JVM, is there some way we could take advantage of that for performance and remove the array bounds checks that occur on every array access?</p>
  
  <p>1) I know that recent JDK supports some array bound check elimination, but since I know at compile time that certain calls are safe, I could remove a lot more safely.</p>
  
  <p>2) Some might think this doesn't affect performance much but it most certainly does, especially in array/computation heavy applications such as scientific computing.</p>
  
  <p>The same question regarding casting. I know something is a certain type, but Java doesn't because its limited type system. Is there some way to just tell the JVM to "trust me" and skip any checks?</p>
  
  <p>I realize there is probably no way to do this as the JVM is generally distributed, could it be reasonable to modify a JVM with this feature? Is this something that has been done?</p>
  
  <p>It's one of the frustrations in compiling a more powerfully typed language to the JVM, it still is hampered by Java's limitations.</p>