title: How can the JVM verify there's no potential operand stack overflow when loading a class?
body: <p>Going over some presentation, I've come across the following claim: When the JVM loads a class, it can analyze its content and make sure <strong>there's no overflow or underflow of the operand stack</strong>. I've found <a href="http://www.google.com/search?q=java%20verify%20%22operand%20stack%22%20overflow%20underflow" rel="noreferrer">a lot of sources</a> that make the same claim, but without specifying how it's done.</p>
  
  <p>It is unclear to me how such verification can be made using static analysis. Say I have a (malicious) method that gets some value as an argument, and uses it to perform a series of pops. At load time, the number of iterations is not known, as it depends on the argument given by the method's caller. Therefore, it seems to me that only at runtime should it be possible to determined whether there will be an underflow or not. What am I missing here?</p>